Skip to content

Instantly share code, notes, and snippets.

@thnee
Created July 27, 2018 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thnee/4be9be5698e9008f837af062873dac13 to your computer and use it in GitHub Desktop.
Save thnee/4be9be5698e9008f837af062873dac13 to your computer and use it in GitHub Desktop.
# Os layer
FROM python:3.7-alpine AS os
# minimal
FROM scratch AS minimal
COPY --from=os /usr/local /usr/local
COPY --from=os /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1
COPY --from=os /lib/libz.so.1 /lib/libz.so.1
COPY --from=os /usr/lib/libsqlite3.so.0 /usr/lib/libsqlite3.so.0
# Server layer
FROM python:3.7-alpine
RUN apk add gcc musl-dev linux-headers
RUN pip install --target=/opt uwsgi
# Application layer
FROM python:3.7-alpine
ENV PYTHONPATH=/opt
RUN pip install --target=/opt Django
RUN /opt/bin/django-admin startproject application /opt
# Replace the python image here with scratch for a minmal distro (requires copying of python binary & libs)
FROM minimal
# Copy Server stuff (uwsgi)
COPY --from=1 /opt /opt
# Copy application
COPY --from=2 /opt /opt
ENV PYTHONPATH=/opt
CMD ["/opt/bin/uwsgi", "--http", ":9090", "--wsgi", "application.wsgi"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment