-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (62 loc) · 2.7 KB
/
Dockerfile
File metadata and controls
72 lines (62 loc) · 2.7 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
72
#############################
# Stage 1: Builder
#############################
FROM python:3.12-slim-bookworm AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y curl && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy requirements and install Python dependencies using a cache mount.
COPY requirements.txt /
RUN --mount=type=cache,target=/root/.cache/pip \
python3 -m pip install --root-user-action=ignore -r requirements.txt && rm requirements.txt
# Download and install FRP client with checksum verification
# FRP version and checksums - update these when upgrading
ARG FRP_VERSION=0.61.1
ARG FRP_AMD64_SHA256=bff260b68ca7b1461182a46c4f34e9709ba32764eed30a15dd94ac97f50a2c40
ARG FRP_ARM64_SHA256=af6366f2b43920ebfe6235dba6060770399ed1fb18601e5818552bd46a7621f8
RUN set -ex; \
ARCH=$(uname -m); \
if [ "$ARCH" = "aarch64" ]; then \
FRP_ARCH="arm64"; \
FRP_SHA256="${FRP_ARM64_SHA256}"; \
else \
FRP_ARCH="amd64"; \
FRP_SHA256="${FRP_AMD64_SHA256}"; \
fi; \
FRP_URL="https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_${FRP_ARCH}.tar.gz"; \
echo "Downloading FRP v${FRP_VERSION} for ${FRP_ARCH}..."; \
curl -fsSL "${FRP_URL}" -o /tmp/frp.tar.gz; \
ACTUAL_SHA256=$(sha256sum /tmp/frp.tar.gz | cut -d' ' -f1); \
if [ "$ACTUAL_SHA256" != "$FRP_SHA256" ]; then \
echo "Checksum verification failed for FRP v${FRP_VERSION} (${FRP_ARCH})"; \
echo "Expected: ${FRP_SHA256}"; \
echo "Got: ${ACTUAL_SHA256}"; \
exit 1; \
fi; \
tar -C /tmp -xzf /tmp/frp.tar.gz; \
cp /tmp/frp_${FRP_VERSION}_linux_${FRP_ARCH}/frpc /usr/local/bin/frpc; \
chmod +x /usr/local/bin/frpc; \
rm -rf /tmp/frp_${FRP_VERSION}_linux_${FRP_ARCH} /tmp/frp.tar.gz; \
echo "FRP client installed successfully"
#############################
# Stage 2: Final Runtime Image
#############################
FROM python:3.12-slim-bookworm
# Copy installed Python packages and FRP client from the builder.
COPY --from=builder /usr/local/ /usr/local/
# Install any runtime apt packages your app needs.
RUN apt-get update && apt-get install -y curl procps && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Add application files.
ADD /ex_app/cs[s] /ex_app/css
ADD /ex_app/im[g] /ex_app/img
ADD /ex_app/j[s] /ex_app/js
ADD /ex_app/l10[n] /ex_app/l10n
ADD /ex_app/li[b] /ex_app/lib
# Copy scripts with the proper permissions.
COPY --chmod=775 healthcheck.sh /
COPY --chmod=775 start.sh /
# Set working directory and define entrypoint/healthcheck.
WORKDIR /ex_app/lib
ENTRYPOINT ["/start.sh", "python3", "main.py"]
HEALTHCHECK --interval=2s --timeout=2s --retries=300 CMD /healthcheck.sh