From 347902d5180600b6a38148e697a5702062ccceb7 Mon Sep 17 00:00:00 2001 From: SimolZimol <70102430+SimolZimol@users.noreply.github.com> Date: Sun, 26 Oct 2025 19:20:32 +0100 Subject: [PATCH] modified: Dockerfile modified: README.md modified: app.py --- Dockerfile | 4 ++-- README.md | 20 ++++++++++++++++++++ app.py | 13 +++++++++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 52f3c2b..889c076 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,5 +26,5 @@ ENV DEMO=$DEMO EXPOSE 5000 -# Production server -CMD ["gunicorn", "-w", "3", "-b", "0.0.0.0:5000", "app:app"] +# Production server (use shell form so $PORT expands in Coolify) +CMD gunicorn -w ${WEB_CONCURRENCY:-3} -b 0.0.0.0:${PORT:-5000} app:app diff --git a/README.md b/README.md index c43bd93..ab5e096 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,26 @@ docker run --rm -p 5000:5000 devanturas-site # Open http://localhost:5000 ``` +## Deploy on Coolify + +You can deploy this app on Coolify using the existing Dockerfile: + +1) Create a new Application in Coolify and choose "Dockerfile" as the build type. + +2) Point it to your repository and path where this project lives. + +3) Environment variables (set in Coolify UI): + - PORT: Coolify usually sets this automatically; the container binds to `0.0.0.0:$PORT`. + - FLASK_DEBUG=false (optional) + - WEB_CONCURRENCY=3 (optional Gunicorn workers override) + - DEMO=... (example passthrough, Dockerfile includes `ENV DEMO=$DEMO`) + +4) Exposed port: 5000 (Dockerfile uses `EXPOSE 5000` and `CMD` binds to `$PORT` with a default of 5000.) + +5) Health check: GET /health should return 200 with `{ "status": "ok" }`. + +No other platform-specific files are required. Coolify will build the image from the Dockerfile and run it with the configured environment. + ## Customization - Add more projects by updating the data structures in `app.py` under `/projects` and the detail routes. - To add Wiki/Issues links per project, populate the `links` dict with `wiki` and `issues` keys. If a project should not expose these, simply omit the keys and the template won’t render them. diff --git a/app.py b/app.py index e56ec0d..474a1b0 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,5 @@ -from flask import Flask, render_template +import os +from flask import Flask, render_template, jsonify app = Flask(__name__) @@ -229,6 +230,11 @@ def contact(): ] return render_template('contact.html', links=contact_links) +# Healthcheck endpoint for platforms like Coolify +@app.route('/health') +def health(): + return jsonify(status='ok'), 200 + # Project detail pages @app.route('/projects/fly-plugin') def fly_plugin(): @@ -436,4 +442,7 @@ def discord_bot_stable_diffusion_amd(): return render_template('project_detail.html', project=project) if __name__ == '__main__': - app.run(debug=True, host='0.0.0.0', port=5000) \ No newline at end of file + # Allow overriding via environment (e.g., Coolify sets PORT) + port = int(os.getenv('PORT', '5000')) + debug = os.getenv('FLASK_DEBUG', 'false').lower() == 'true' + app.run(debug=debug, host='0.0.0.0', port=port) \ No newline at end of file