2
0

Dockerfile 2.5 KB

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