Dockerfile 2.1 KB

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