Created
August 4, 2018 20:39
-
-
Save ZipFile/b2b059debeaaf16f0d5abe199e7fbd84 to your computer and use it in GitHub Desktop.
Multistage build with private repo on GitHub. Python/Django app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:bionic as build-base | |
ENV PYTHONUNBUFFERED 1 | |
ARG SSH_KEY | |
RUN apt-get update && \ | |
apt-get install -y build-essential \ | |
libprotobuf-dev \ | |
libhiredis-dev \ | |
libxml2-dev \ | |
libxslt1-dev \ | |
python3-all-dev \ | |
python3-venv \ | |
postgresql-server-dev-all \ | |
git \ | |
openssh-client | |
RUN mkdir -p /root/.ssh | |
RUN ssh-keyscan github.com > /root/.ssh/known_hosts | |
RUN echo "$SSH_KEY" > /root/.ssh/id_rsa && chmod 0600 /root/.ssh/id_rsa | |
COPY . /app | |
WORKDIR /app | |
RUN python3 -m venv /env | |
ENV PATH "/env/bin:$PATH" | |
RUN pip install --upgrade pip setuptools wheel | |
RUN pip install --upgrade raven | |
RUN pip install --upgrade grpcio grpcio-tools | |
RUN pip install git+ssh://git@github.com/mycorp/myproj-utils.git#egg=myproj-utils[kube,sentry] | |
RUN pip install -e . | |
RUN pip uninstall -y grpcio-tools | |
FROM ubuntu:bionic | |
RUN adduser --system --ingroup users user | |
RUN apt-get update && \ | |
apt-get install -y ca-certificates \ | |
libprotobuf10 \ | |
libhiredis0.13 \ | |
python3-all \ | |
libxml2 \ | |
libxslt1.1 \ | |
postgresql-client \ | |
uwsgi \ | |
uwsgi-plugin-python3 | |
COPY --from=build-base /env /env | |
COPY --from=build-base /app /app | |
WORKDIR /app | |
ENV PATH "/env/bin:$PATH" | |
ENV PYTHONUNBUFFERED 1 | |
ENV DJANGO_SETTINGS_MODULE "myproj.settings" | |
ENV GRPC_ENABLE_FORK_SUPPORT "True" | |
USER user:users | |
ENTRYPOINT ["./manage.py"] |
Author
ZipFile
commented
Aug 4, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment