-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(docker): shorten dockerfile
- Loading branch information
Showing
2 changed files
with
19 additions
and
35 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
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,49 +1,36 @@ | ||
FROM python:3.11-slim-bullseye AS builder | ||
FROM python:3.11-slim-bullseye AS base | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
FROM base AS builder | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
|
||
FROM python:3.11-slim-bullseye AS development | ||
|
||
FROM base AS development | ||
WORKDIR /app | ||
|
||
COPY --from=builder /usr/local/bin /usr/local/bin | ||
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages | ||
|
||
ENV FLASK_APP=app.py | ||
ENV FLASK_ENV=development | ||
ENV FLASK_RUN_PORT=5000 | ||
ENV FLASK_RUN_HOST=0.0.0.0 | ||
|
||
ENV FLASK_APP=app.py \ | ||
FLASK_ENV=development \ | ||
FLASK_RUN_PORT=5000 \ | ||
FLASK_RUN_HOST=0.0.0.0 | ||
EXPOSE 5000 | ||
|
||
CMD ["flask", "run"] | ||
|
||
|
||
FROM python:3.11-slim-bullseye AS gunicorn | ||
FROM base AS gunicorn | ||
RUN pip install --no-cache-dir gunicorn | ||
|
||
|
||
FROM python:3.11-slim-bullseye AS production | ||
|
||
WORKDIR /app | ||
FROM base AS production | ||
|
||
COPY --from=builder /usr/local/bin /usr/local/bin | ||
|
||
COPY --from=gunicorn /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages | ||
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages | ||
COPY --from=gunicorn /usr/local/bin /usr/local/bin | ||
COPY --from=gunicorn /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages | ||
|
||
COPY . . | ||
|
||
ENV GUNICORN_CMD_ARGS="--bind=0.0.0.0:5000 --workers=3" | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["gunicorn", "app:app"] | ||
CMD ["gunicorn", "app:app"] |