Dockerfile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. ENV PORT 8000
  40. EXPOSE 8000
  41. # Add custom environment variables needed by Django or your settings file here:
  42. ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
  43. # Call collectstatic with dummy environment variables:
  44. RUN DATABASE_URL=postgres://none REDIS_URL=none /venv/bin/python manage.py collectstatic --noinput
  45. # make sure static files are writable by uWSGI process
  46. RUN mkdir -p /code/bakerydemo/media/images && chown -R 1000:2000 /code/bakerydemo/media
  47. # mark the destination for images as a volume
  48. VOLUME ["/code/bakerydemo/media/images/"]
  49. # start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
  50. ENTRYPOINT ["/code/docker-entrypoint.sh"]
  51. # Start uWSGI
  52. CMD ["/venv/bin/uwsgi", "/code/etc/uwsgi.ini"]