-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (59 loc) · 2.86 KB
/
Dockerfile
File metadata and controls
71 lines (59 loc) · 2.86 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
FROM docker.io/python:3.12-slim-bookworm AS builder
RUN apt-get update && apt-get install -y curl && \
apt-get clean && rm -rf /var/lib/apt/lists/*
ARG BUILD_TYPE
COPY 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"
# Installing PyTorch based on BUILD_TYPE
RUN --mount=type=cache,target=/root/.cache/pip \
ARCH=$(uname -m) && \
if [ "$ARCH" = "aarch64" ]; then \
echo "Installing PyTorch for ARM64"; \
python3 -m pip install --root-user-action=ignore torch==2.8.0 torchvision; \
elif [ "$BUILD_TYPE" = "rocm" ]; then \
python3 -m pip install --root-user-action=ignore torch==2.8.0 torchvision --index-url https://download.pytorch.org/whl/rocm6.4; \
elif [ "$BUILD_TYPE" = "cpu" ]; then \
python3 -m pip install --root-user-action=ignore torch==2.8.0 torchvision --index-url https://download.pytorch.org/whl/cpu; \
else \
python3 -m pip install --root-user-action=ignore torch==2.8.0 torchvision; \
fi
RUN --mount=type=cache,target=/root/.cache/pip \
python3 -m pip install --root-user-action=ignore -r requirements.txt && rm requirements.txt
FROM python:3.12-slim-bookworm
COPY --from=builder /usr/local/ /usr/local/
RUN apt-get update && apt-get install -y curl procps iputils-ping netcat-traditional && \
apt-get clean && rm -rf /var/lib/apt/lists/*
ADD /ex_app/lib /ex_app/lib
COPY --chmod=775 healthcheck.sh /
COPY --chmod=775 start.sh /
WORKDIR /ex_app/lib
ENTRYPOINT ["/start.sh", "python3", "main.py"]
HEALTHCHECK --interval=2s --timeout=2s --retries=300 CMD /healthcheck.sh