Skip to content

Commit

Permalink
Update Dockerfile for smaller image size
Browse files Browse the repository at this point in the history
- Smaller image size isn't everything, but when you can shrink the operational image size by 60% its an obvious decision.
- Update to Python 3.8
  • Loading branch information
joekottke committed Oct 18, 2020
1 parent c703e43 commit d05e60d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
FROM python:3.7.4-alpine3.10
FROM python:3.8-alpine3.10 as compile
RUN mkdir /app
WORKDIR /app
RUN apk add --no-cache curl
RUN curl -O -fssL https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.3.0/grpc_health_probe-linux-amd64 && \
mv grpc_health_probe-linux-amd64 /usr/local/bin/grpc_health_probe && \
chmod 755 /usr/local/bin/grpc_health_probe
RUN apk add --no-cache libstdc++
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt /app
RUN apk add --no-cache --virtual build-deps build-base && \
pip install --no-cache-dir -r requirements.txt && \
apk del build-deps

FROM python:3.8-alpine3.10
RUN apk add --no-cache libstdc++
RUN mkdir /app
WORKDIR /app
COPY src/ /app/
COPY --from=compile /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN python -m grpc_tools.protoc \
-I. \
--python_out=. \
Expand Down

0 comments on commit d05e60d

Please sign in to comment.