Dockerfile 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. curl \
  24. git \
  25. libexpat1-dev \
  26. libjpeg62-turbo-dev \
  27. libpcre3-dev \
  28. libpq-dev \
  29. zlib1g-dev \
  30. " \
  31. && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
  32. && python3.9 -m venv /venv \
  33. && /venv/bin/pip install -U pip \
  34. && /venv/bin/pip install --no-cache-dir -r /requirements/production.txt \
  35. && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
  36. && rm -rf /var/lib/apt/lists/*
  37. RUN mkdir /code/
  38. WORKDIR /code/
  39. ADD . /code/
  40. ENV PORT 8000
  41. EXPOSE 8000
  42. # Add custom environment variables needed by Django or your settings file here:
  43. ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
  44. # Call collectstatic with dummy environment variables:
  45. RUN DATABASE_URL=postgres://none REDIS_URL=none /venv/bin/python manage.py collectstatic --noinput
  46. # make sure static files are writable by uWSGI process
  47. RUN mkdir -p /code/bakerydemo/media/images && chown -R 1000:2000 /code/bakerydemo/media
  48. # mark the destination for images as a volume
  49. VOLUME ["/code/bakerydemo/media/images/"]
  50. # start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
  51. ENTRYPOINT ["/code/docker-entrypoint.sh"]
  52. # Start uWSGI
  53. CMD ["/venv/bin/uwsgi", "/code/etc/uwsgi.ini"]