Dockerfile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. FROM python:3.12-slim
  2. ARG NIGHTLY=0
  3. # Install packages needed to run your application (not build deps):
  4. # We need to recreate the /usr/share/man/man{1..8} directories first because
  5. # they were clobbered by a parent image.
  6. RUN set -ex \
  7. && RUN_DEPS=" \
  8. libexpat1 \
  9. libjpeg62-turbo \
  10. libpcre3 \
  11. libpq5 \
  12. mime-support \
  13. postgresql-client \
  14. procps \
  15. zlib1g \
  16. " \
  17. && seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \
  18. && apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
  19. && rm -rf /var/lib/apt/lists/*
  20. ADD requirements/ /requirements/
  21. ENV VIRTUAL_ENV=/venv PATH=/venv/bin:$PATH PYTHONPATH=/code/
  22. RUN set -ex \
  23. && BUILD_DEPS=" \
  24. build-essential \
  25. curl \
  26. git \
  27. libexpat1-dev \
  28. libjpeg62-turbo-dev \
  29. libpcre3-dev \
  30. libpq-dev \
  31. zlib1g-dev \
  32. " \
  33. && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
  34. && if [ "$NIGHTLY" = "1" ]; then \
  35. NIGHTLY_URL=$(curl -s https://releases.wagtail.org/nightly/latest.json | \
  36. grep -o 'https://[^"]*') \
  37. && sed -i "s|wagtail>=.*|${NIGHTLY_URL}|" /requirements/base.txt; \
  38. fi \
  39. && python3.12 -m venv ${VIRTUAL_ENV} \
  40. && python3.12 -m pip install -U pip \
  41. && python3.12 -m pip install --no-cache-dir -r /requirements/production.txt \
  42. && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
  43. && rm -rf /var/lib/apt/lists/*
  44. RUN mkdir /code/
  45. WORKDIR /code/
  46. ADD . /code/
  47. ENV PORT=8000
  48. EXPOSE 8000
  49. # Add custom environment variables needed by Django or your settings file here:
  50. ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
  51. # Call collectstatic with dummy environment variables:
  52. RUN DATABASE_URL=postgres://none REDIS_URL=none python manage.py collectstatic --noinput
  53. # make sure static files are writable by uWSGI process
  54. RUN mkdir -p /code/bakerydemo/media/images && mkdir -p /code/bakerydemo/media/original_images && chown -R 1000:2000 /code/bakerydemo/media
  55. # mark the destination for images as a volume
  56. VOLUME ["/code/bakerydemo/media/images/"]
  57. # start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
  58. ENTRYPOINT ["/code/docker-entrypoint.sh"]
  59. # Start uWSGI
  60. CMD ["uwsgi", "/code/etc/uwsgi.ini"]