Skip to content

Conversation

@dylanschultzie
Copy link

@dylanschultzie dylanschultzie commented May 6, 2025

Key changes:

  1. use gunicorn in front of flask. Gunicorn enhances Flask's performance and security in production by managing multiple workers and facilitating the use of a reverse proxy.
  2. update dockerfile to use uv
  3. add example docker-compose file
  4. add pyproject.toml
  5. add ruff for dev builds

Signed-off-by: Dylan Schultz <[email protected]>
Signed-off-by: Dylan Schultz <[email protected]>
Signed-off-by: Dylan Schultz <[email protected]>
Signed-off-by: Dylan Schultz <[email protected]>
Signed-off-by: Dylan Schultz <[email protected]>
@danbryan danbryan marked this pull request as draft May 18, 2025 22:21
@danbryan
Copy link
Contributor

Hey @dylanschultzie just checking in on this WIP. Last i heard you said it wasn't ready to be reviewed yet. I'v moved it to draft for the time being, but lemme know when your ready for review, and happy to give it a look

@dylanschultzie dylanschultzie marked this pull request as ready for review May 19, 2025 17:19
@dylanschultzie
Copy link
Author

@danbryan ready for review 👍

@dylanschultzie dylanschultzie changed the title [WIP] Upstream docker/venv improvements Upstream docker/venv improvements May 19, 2025
@danbryan
Copy link
Contributor

Hey @dylanschultzie , I tested out the changes tonight and I think this is a good idea. I’m not very experienced with Gunicorn or uv, so I spent some time reading up and experimenting.

One thing I ran into: I wasn’t able to get the same detailed, rolling logs with Gunicorn as I do when running the app directly with python app.py (see screenshot).
image

I tried several Gunicorn options, including:

gunicorn -w 4 -b 0.0.0.0:5001 app:app --access-logfile - --error-logfile - --capture-output

but couldn’t replicate the same log output. Do you know if there’s a way to achieve this with Gunicorn, or is there a recommended approach for getting similar logs in production?

Also, I’d suggest updating the setup so that docker-compose reads the Flask port from the .env file, rather than hardcoding it. Along those lines, it might be best to remove the EXPOSE instruction from the Dockerfile and let Compose or other orchestration tools handle port exposure, which would make the setup more flexible.

Thanks again for your work on this and any advice you can share about logging!

@dylanschultzie
Copy link
Author

@danbryan those are all great suggestions, I'll see if I can figure out the logging difference shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants