-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (33 loc) · 1.14 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# copy source code
FROM alpine:3.18 as code-layer
WORKDIR /db-backups
COPY src .
FROM python:3.12-slim-bookworm
ARG POETRY_VERSION="1.7.1"
ARG PIP_DEFAULT_TIMEOUT=300
WORKDIR /db-backups
RUN groupadd -r db-backups && useradd -r -g db-backups db-backups
COPY pyproject.toml .
COPY poetry.lock .
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3-dev \
openssl \
postgresql-client-15 \
&& pip install poetry==${POETRY_VERSION} \
&& poetry config --local virtualenvs.create false \
&& PIP_DEFAULT_TIMEOUT=${PIP_DEFAULT_TIMEOUT} poetry install --no-root --only=main --no-cache --no-ansi --no-interaction \
&& pip uninstall -y poetry poetry-core \
&& apt-get purge -y --auto-remove python3-dev \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir ./backups ./logs
RUN chown -R db-backups:db-backups ./backups
RUN chown -R db-backups:db-backups ./logs
VOLUME ./backups ./logs
COPY --from=code-layer --chown=db-backups:db-backups /db-backups ./src
ENV LOCAL_PATH_IN_CONTAINER=./backups \
LOG_PATH=./logs
USER db-backups
ENTRYPOINT ["python", "-m", "src.run"]