Skip to content

Instantly share code, notes, and snippets.

@kemingy
Last active July 24, 2020 10:06
Show Gist options
  • Save kemingy/ff90b7df88833b7adc698a85fc526ab5 to your computer and use it in GitHub Desktop.
Save kemingy/ff90b7df88833b7adc698a85fc526ab5 to your computer and use it in GitHub Desktop.
dockerfile for production, python
  • from image version FROM python:3.8.5-buster
  • package version fixed in requirements.txt file
  • build cache
  • non-root user
    RUN useradd --create-home appuser
    WORKDIR /home/appuser
    USER appuser
    
  • don't use alpine (slow, bug)
  • Gunicorn config:
    • shared memory gunicorn --worker-tmp-dir /dev/shm ...
    • workers and threads gunicorn --workers=2 --threads=4 --worker-class=gthread ...
    • logging gunicorn --log-file=- ...
  • activate conda env in Dockerfile: SHELL ["conda", "run", "-n", "myenv", "/bin/bash", "-c"]

Refs

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