Skip to content

Instantly share code, notes, and snippets.

@NathanHowell
Created July 28, 2017 21:52
Show Gist options
  • Save NathanHowell/52983639fb0b7de6605ecd506d9b7817 to your computer and use it in GitHub Desktop.
Save NathanHowell/52983639fb0b7de6605ecd506d9b7817 to your computer and use it in GitHub Desktop.
Example of multistage Docker build for grpc
FROM alpine:3.6 AS base
RUN apk add --no-cache python3 ca-certificates tzdata tini \
&& apk upgrade --no-cache
FROM base AS build
RUN apk add --no-cache \
python3-dev \
cython \
build-base
COPY requirements.txt /app/
RUN pip3 install --no-cache-dir --upgrade -r /app/requirements.txt
FROM base
COPY --from=build /usr/lib/python3.6/site-packages/ /usr/lib/python3.6/site-packages/
WORKDIR /app/
COPY foo.py /app/
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/usr/bin/env", "python3", "foo.py"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment