Skip to content

Commit 48b14fe

Browse files
committed
updates
1 parent d26cbab commit 48b14fe

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

project/Dockerfile.prod

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
###########
2+
# BUILDER #
3+
###########
4+
5+
# pull official base image
6+
FROM python:3.13.3-slim-bookworm as builder
7+
8+
# install system dependencies
9+
RUN apt-get update \
10+
&& apt-get -y install netcat-traditional gcc postgresql \
11+
&& apt-get clean
12+
13+
# set work directory
14+
WORKDIR /usr/src/app
15+
16+
# set environment variables
17+
ENV PYTHONDONTWRITEBYTECODE 1
18+
ENV PYTHONUNBUFFERED 1
19+
20+
# install dependencies
21+
RUN pip install --upgrade pip
22+
COPY ./requirements.txt .
23+
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
24+
25+
# lint
26+
COPY . /usr/src/app/
27+
RUN pip install black==25.1.0 flake8==7.2.0 isort==6.0.1
28+
RUN flake8 .
29+
RUN black --exclude=migrations . --check
30+
RUN isort . --check-only
31+
32+
33+
#########
34+
# FINAL #
35+
#########
36+
137
# pull official base image
238
FROM python:3.13.3-slim-bookworm
339

@@ -25,16 +61,17 @@ RUN apt-get update \
2561
&& apt-get clean
2662

2763
# install python dependencies
64+
COPY --from=builder /usr/src/app/wheels /wheels
65+
COPY --from=builder /usr/src/app/requirements.txt .
2866
RUN pip install --upgrade pip
29-
COPY ./requirements.txt .
30-
RUN pip install -r requirements.txt
67+
RUN pip install --no-cache /wheels/*
3168
RUN pip install "uvicorn[standard]==0.34.1"
3269

3370
# add app
3471
COPY . .
3572

3673
# chown all the files to the app user
37-
RUN chown -R app:app $APP_HOME
74+
RUN chown -R app:app $HOME
3875

3976
# change to the app user
4077
USER app

0 commit comments

Comments
 (0)