-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (54 loc) · 2.12 KB
/
Dockerfile
File metadata and controls
71 lines (54 loc) · 2.12 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# syntax=docker/dockerfile:1.7
# ─── Builder stage ──────────────────────────────────────────────────────────
FROM python:3.12-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /build
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libffi-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
COPY pyproject.toml ReadMe.md LICENSE ./
COPY src/ ./src/
COPY main.py ./
RUN pip install --upgrade pip build \
&& python -m build --wheel --outdir /wheels
# ─── Runtime stage ──────────────────────────────────────────────────────────
FROM python:3.12-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
BACKUP_HANDLER_LOG_JSON=1
# Runtime OS dependencies:
# - openssh-client: SSH/SFTP backups
# - default-mysql-client: mysqldump
# - rsync, tar: used by snapshots
# - ca-certificates: TLS for S3/webhooks
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
openssh-client \
default-mysql-client \
rsync \
tar \
&& rm -rf /var/lib/apt/lists/*
# Non-root user
ARG APP_UID=10001
ARG APP_GID=10001
RUN groupadd --system --gid "${APP_GID}" backup \
&& useradd --system --uid "${APP_UID}" --gid "${APP_GID}" \
--home /app --shell /usr/sbin/nologin backup
WORKDIR /app
COPY --from=builder /wheels /wheels
RUN pip install --no-cache-dir /wheels/*.whl && rm -rf /wheels
COPY --chown=backup:backup config/ ./config/
RUN mkdir -p /app/Logs /app/BackupTimestamp /app/snapshots \
&& chown -R backup:backup /app
USER backup
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD backup-handler --version || exit 1
ENTRYPOINT ["backup-handler"]
CMD ["--help"]