Dockerfile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. && apk add libjpeg-turbo pcre
  29. RUN apk add --no-cache postgresql-client
  30. RUN mkdir /code/
  31. WORKDIR /code/
  32. ADD . /code/
  33. EXPOSE 8000
  34. # Add custom environment variables needed by Django or your settings file here:
  35. ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
  36. # uWSGI configuration (customize as needed):
  37. 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
  38. # Call collectstatic with dummy environment variables:
  39. RUN DATABASE_URL=postgres://none REDIS_URL=none /venv/bin/python manage.py collectstatic --noinput
  40. # make sure static files are writable by uWSGI process
  41. RUN chown -R 1000:2000 /code/bakerydemo/media
  42. # start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
  43. ENTRYPOINT ["/code/docker-entrypoint.sh"]
  44. CMD ["/venv/bin/uwsgi", "--http-auto-chunked", "--http-keepalive", "--static-map", "/media/=/code/bakerydemo/media/"]