Dockerfile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. FROM python:3.5-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. git \
  16. && pyvenv /venv \
  17. && /venv/bin/pip install -U pip \
  18. && LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "/venv/bin/pip install -r /requirements/production.txt" \
  19. && runDeps="$( \
  20. scanelf --needed --nobanner --recursive /venv \
  21. | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
  22. | sort -u \
  23. | xargs -r apk info --installed \
  24. | sort -u \
  25. )" \
  26. && apk add --virtual .python-rundeps $runDeps \
  27. && apk del .build-deps
  28. RUN apk add --no-cache postgresql-client
  29. RUN mkdir /code/
  30. WORKDIR /code/
  31. ADD . /code/
  32. EXPOSE 8000
  33. # Add custom environment variables needed by Django or your settings file here:
  34. ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
  35. # uWSGI configuration (customize as needed):
  36. 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
  37. # Call collectstatic with dummy environment variables:
  38. RUN DATABASE_URL=postgres://none REDIS_URL=none /venv/bin/python manage.py collectstatic --noinput
  39. # make sure static files are writable by uWSGI process
  40. RUN chown -R 1000:2000 /code/bakerydemo/media
  41. # start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
  42. ENTRYPOINT ["/code/docker-entrypoint.sh"]
  43. CMD ["/venv/bin/uwsgi", "--http-auto-chunked", "--http-keepalive", "--static-map", "/media/=/code/bakerydemo/media/"]