Dockerfile 1.5 KB

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