Dockerfile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. FROM python:3.7-slim
  2. # Install packages needed to run your application (not build deps):
  3. # We need to recreate the /usr/share/man/man{1..8} directories first because
  4. # they were clobbered by a parent image.
  5. RUN set -ex \
  6. && RUN_DEPS=" \
  7. libexpat1 \
  8. libjpeg62-turbo \
  9. libpcre3 \
  10. libpq5 \
  11. mime-support \
  12. postgresql-client \
  13. zlib1g \
  14. " \
  15. && seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \
  16. && apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
  17. && rm -rf /var/lib/apt/lists/*
  18. ADD requirements/ /requirements/
  19. RUN set -ex \
  20. && BUILD_DEPS=" \
  21. build-essential \
  22. git \
  23. libexpat1-dev \
  24. libjpeg62-turbo-dev \
  25. libpcre3-dev \
  26. libpq-dev \
  27. zlib1g-dev \
  28. " \
  29. && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
  30. && python3.7 -m venv /venv \
  31. && /venv/bin/pip install -U pip \
  32. && /venv/bin/pip install --no-cache-dir -r /requirements/production.txt \
  33. && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
  34. && rm -rf /var/lib/apt/lists/*
  35. RUN mkdir /code/
  36. WORKDIR /code/
  37. ADD . /code/
  38. EXPOSE 8000
  39. # Add custom environment variables needed by Django or your settings file here:
  40. ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
  41. # Tell uWSGI where to find your wsgi file:
  42. ENV UWSGI_WSGI_FILE=bakerydemo/wsgi_production.py
  43. # Base uWSGI configuration (you shouldn't need to change these):
  44. ENV UWSGI_VIRTUALENV=/venv UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_HTTP_AUTO_CHUNKED=1 UWSGI_HTTP_KEEPALIVE=1 UWSGI_UID=1000 UWSGI_GID=2000 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy
  45. # Number of uWSGI workers and threads per worker (customize as needed):
  46. ENV UWSGI_WORKERS=2 UWSGI_THREADS=4
  47. # uWSGI uploaded media file serving configuration:
  48. ENV UWSGI_STATIC_MAP="/media/=/code/bakerydemo/media/"
  49. # Call collectstatic with dummy environment variables:
  50. RUN DATABASE_URL=postgres://none REDIS_URL=none /venv/bin/python manage.py collectstatic --noinput
  51. # make sure static files are writable by uWSGI process
  52. RUN chown -R 1000:2000 /code/bakerydemo/media
  53. # mark the destination for images as a volume
  54. VOLUME ["/code/bakerydemo/media/images/"]
  55. # start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
  56. ENTRYPOINT ["/code/docker-entrypoint.sh"]
  57. # Start uWSGI
  58. CMD ["/venv/bin/uwsgi", "--show-config"]