Multistage Dockerfile for small image

(Bryce Roche) #1

FROM python:3.7-slim-stretch AS builder

COPY . /app
WORKDIR /app

RUN apt-get update && apt-get install -y git python3-dev gcc
&& rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade -r requirements.txt

FROM python:3.7-slim
WORKDIR /app
COPY --from=builder /app/ /app/
ENV PORT 8080
CMD [ “python”, “app.py” ]

0 Likes

(Bryce Roche) #2

FROM python:3.7-slim-stretch AS builder

COPY . /app
WORKDIR /app

RUN apt-get update && apt-get install -y git python3-dev gcc
&& rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade -r requirements.txt

FROM python:3.7-slim-stretch
WORKDIR /app
COPY --from=builder /app/ /app/
ENV PORT 8080
CMD [ “python”, “app.py” ]

0 Likes