-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (56 loc) · 1.72 KB
/
Dockerfile
File metadata and controls
71 lines (56 loc) · 1.72 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
# Stage 1: builder for Python dependencies
FROM python:3.13.12-alpine AS builder
ENV \
PIP_NO_CACHE_DIR=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random
# Install build tools
RUN apk update && apk add --no-cache \
gcc \
musl-dev \
libffi-dev \
openssl-dev \
cargo \
rust \
openssl
# Create non-root build user
RUN addgroup -g 1000 builduser && \
adduser -u 1000 -G builduser -D -s /bin/bash builduser
USER builduser
WORKDIR /home/builduser
# Copy only requirements
COPY requirements.txt .
# Install secure pinned Python deps
RUN python3 -m pip install --upgrade pip setuptools wheel && \
python3 -m pip install --user -r requirements.txt
# Final runtime stage
FROM python:3.13.12-alpine AS runtime
ENV \
PATH="/home/appuser/.local/bin:$PATH" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random
# Install only runtime packages
RUN apk update && apk add --no-cache \
bash \
tini \
grep \
coreutils \
&& rm -rf /var/cache/apk/*
# Create non-root app user
RUN addgroup -g 1000 appuser && \
adduser -u 1000 -G appuser -D -s /bin/bash -h /home/appuser appuser
USER appuser
WORKDIR /home/appuser
# Copy installed packages from builder
COPY --from=builder --chown=appuser:appuser /home/builduser/.local /home/appuser/.local
# Copy application code
COPY --chown=appuser:appuser . .
# Healthcheck
HEALTHCHECK --interval=60m --timeout=10s --start-period=10s --retries=3 \
CMD curl -f https://securenote.link/api/v1/health || exit 1
# Entrypoint with tini for signal handling
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["python3", "secure_note_mcp.py"]