|
| 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 | + |
1 | 37 | # pull official base image |
2 | 38 | FROM python:3.13.3-slim-bookworm |
3 | 39 |
|
@@ -25,16 +61,17 @@ RUN apt-get update \ |
25 | 61 | && apt-get clean |
26 | 62 |
|
27 | 63 | # install python dependencies |
| 64 | +COPY --from=builder /usr/src/app/wheels /wheels |
| 65 | +COPY --from=builder /usr/src/app/requirements.txt . |
28 | 66 | RUN pip install --upgrade pip |
29 | | -COPY ./requirements.txt . |
30 | | -RUN pip install -r requirements.txt |
| 67 | +RUN pip install --no-cache /wheels/* |
31 | 68 | RUN pip install "uvicorn[standard]==0.34.1" |
32 | 69 |
|
33 | 70 | # add app |
34 | 71 | COPY . . |
35 | 72 |
|
36 | 73 | # chown all the files to the app user |
37 | | -RUN chown -R app:app $APP_HOME |
| 74 | +RUN chown -R app:app $HOME |
38 | 75 |
|
39 | 76 | # change to the app user |
40 | 77 | USER app |
|
0 commit comments