Dockerfile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. FROM python:3.7-alpine
  2. ADD requirements/ /requirements/
  3. RUN set -ex \
  4. && apk add --no-cache --virtual .build-deps \
  5. gcc \
  6. g++ \
  7. make \
  8. libc-dev \
  9. musl-dev \
  10. linux-headers \
  11. pcre-dev \
  12. postgresql-dev \
  13. libjpeg-turbo-dev \
  14. zlib-dev \
  15. expat-dev \
  16. git \
  17. && pyvenv /venv \
  18. && /venv/bin/pip install -U pip \
  19. && LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "/venv/bin/pip install -r /requirements/production.txt" \
  20. && runDeps="$( \
  21. scanelf --needed --nobanner --recursive /venv \
  22. | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
  23. | sort -u \
  24. | xargs -r apk info --installed \
  25. | sort -u \
  26. )" \
  27. && apk add --virtual .python-rundeps $runDeps \
  28. && apk del .build-deps \
  29. && apk add libjpeg-turbo pcre
  30. RUN apk add --no-cache postgresql-client
  31. RUN mkdir /code/
  32. WORKDIR /code/
  33. ADD . /code/
  34. EXPOSE 8000
  35. # Add custom environment variables needed by Django or your settings file here:
  36. ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
  37. # uWSGI configuration (customize as needed):
  38. ENV UWSGI_VIRTUALENV=/venv UWSGI_WSGI_FILE=bakerydemo/wsgi_production.py UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_WORKERS=2 UWSGI_THREADS=8 UWSGI_UID=1000 UWSGI_GID=2000
  39. # Call collectstatic with dummy environment variables:
  40. RUN DATABASE_URL=postgres://none REDIS_URL=none /venv/bin/python manage.py collectstatic --noinput
  41. # make sure static files are writable by uWSGI process
  42. RUN chown -R 1000:2000 /code/bakerydemo/media
  43. # start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
  44. ENTRYPOINT ["/code/docker-entrypoint.sh"]
  45. CMD ["/venv/bin/uwsgi", "--http-auto-chunked", "--http-keepalive", "--static-map", "/media/=/code/bakerydemo/media/"]