-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting the dockerfiles into multi-stage builds.
Previously if you edited `main.py` and rebuilt the image, you'd redownload all the python deps again, needlessly. Now you can change main.py without triggering a needless `pip install`. It's a much snappier development experience.
- Loading branch information
1 parent
f8aa891
commit db2fb44
Showing
3 changed files
with
52 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
FROM python:3.11.1-slim-buster | ||
# Dependency-building stage. | ||
FROM python:3.11.1-slim-buster AS build | ||
|
||
ENV DEBIAN_FRONTEND="noninteractive" | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV PYTHONIOENCODING=UTF-8 | ||
|
||
WORKDIR /app | ||
RUN python3 -m venv env | ||
ENV PATH="env/bin:$PATH" | ||
|
||
COPY requirements.txt . | ||
RUN python3 -m pip install -r requirements.txt | ||
|
||
# Runtime stage. | ||
FROM python:3.11.1-slim-buster AS runtime | ||
|
||
WORKDIR /app | ||
COPY --from=build /app/env /app/env | ||
ENV PATH="env/bin:$PATH" | ||
|
||
COPY . . | ||
RUN find | grep requirements.txt | xargs -I '{}' python3 -m pip install -r '{}' --extra-index-url https://pkgs.dev.azure.com/quix-analytics/53f7fe95-59fe-4307-b479-2473b96de6d1/_packaging/public/pypi/simple/ | ||
ENTRYPOINT ["python3", "main.py"] | ||
|
||
ENTRYPOINT ["env/bin/python3", "main.py"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
FROM python:3.11.1-slim-buster | ||
# Dependency-building stage. | ||
FROM python:3.11.1-slim-buster AS build | ||
|
||
ENV DEBIAN_FRONTEND="noninteractive" | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV PYTHONIOENCODING=UTF-8 | ||
|
||
WORKDIR /app | ||
RUN python3 -m venv env | ||
ENV PATH="env/bin:$PATH" | ||
|
||
COPY requirements.txt . | ||
RUN python3 -m pip install -r requirements.txt | ||
|
||
# Runtime stage. | ||
FROM python:3.11.1-slim-buster AS runtime | ||
|
||
WORKDIR /app | ||
COPY --from=build /app/env /app/env | ||
ENV PATH="env/bin:$PATH" | ||
|
||
COPY . . | ||
RUN find | grep requirements.txt | xargs -I '{}' python3 -m pip install -r '{}' --extra-index-url https://pkgs.dev.azure.com/quix-analytics/53f7fe95-59fe-4307-b479-2473b96de6d1/_packaging/public/pypi/simple/ | ||
ENTRYPOINT ["python3", "main.py"] | ||
|
||
ENTRYPOINT ["env/bin/python3", "main.py"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
FROM python:3.11.1-slim-buster | ||
# Dependency-building stage. | ||
FROM python:3.11.1-slim-buster AS build | ||
|
||
ENV DEBIAN_FRONTEND="noninteractive" | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV PYTHONIOENCODING=UTF-8 | ||
|
||
WORKDIR /app | ||
RUN python3 -m venv env | ||
ENV PATH="env/bin:$PATH" | ||
|
||
COPY requirements.txt . | ||
RUN python3 -m pip install -r requirements.txt | ||
|
||
|
||
# Runtime stage. | ||
FROM python:3.11.1-slim-buster AS runtime | ||
|
||
WORKDIR /app | ||
COPY --from=build /app/env /app/env | ||
ENV PATH="env/bin:$PATH" | ||
|
||
COPY . . | ||
RUN find | grep requirements.txt | xargs -I '{}' python3 -m pip install -r '{}' --extra-index-url https://pkgs.dev.azure.com/quix-analytics/53f7fe95-59fe-4307-b479-2473b96de6d1/_packaging/public/pypi/simple/ | ||
ENTRYPOINT ["python3", "main.py"] | ||
|
||
ENTRYPOINT ["env/bin/python3", "main.py"] |