Flask Docker generator should not use `flask run`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 50/100
Research direction
Start with scanner/templates/flask/Dockerfile and compare its current command with Flask’s deployment guidance linked in the issue. Check how the generated image is expected to expose and start the application, then update the template to use a production WSGI server instead of flask run. Done means generated Flask deployments no longer emit the development-server warning.
Written by the indexing model from the issue text.
Description
The generated Dockerfile for flask should have a different CMD.
Right now it runs python3 -m flask run. This is incorrect. Flask warns about this in their docs:
Do not use the development server when deploying to production. It is intended for use only during local development. It is not designed to be particularly secure, stable, or efficient.
When you look at the fly logs, it also emits a warning:
This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
I’d propose the following changes:
diff --git a/Dockerfile b/Dockerfile
index 7f8924f..ce75327 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,9 +10,10 @@ WORKDIR /code
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
+RUN pip3 install gunicorn
COPY . .
EXPOSE 8080
-CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0", "--port=8080"]
+CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]
This will do the following:
- Installs
requirements.txt - If gunicorn was installed already from the requirements file, pip3 install gunicorn is a noop. Otherwise it will install the latest version.
- Updates the default Dockerfile to use gunicorn, rather than the flask debug server
Alternatively, you could look for gunicorn in requirements.txt and add if it’s missing.
- Dominant language
- Go
- Stars
- 1.7k
- Forks
- 311
- Avg merge
- 12h 50m
- Merged PRs (30d)
- 78
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from superfly/flyctl
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100