-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathDockerfile.ci
More file actions
57 lines (46 loc) · 1.99 KB
/
Copy pathDockerfile.ci
File metadata and controls
57 lines (46 loc) · 1.99 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
# CI-specific Dockerfile
# Assumes binaries and static files are already built and available in the context
FROM alpine:latest
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /app
ENV GIN_MODE=release
# Install dependencies and cloudflared
RUN apk add --no-cache tzdata ca-certificates curl && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
arch="${TARGETARCH:-$(uname -m)}" && \
variant="${TARGETVARIANT:-}" && \
case "$arch" in \
amd64|x86_64) cloudflared_arch="amd64" ;; \
arm64|aarch64) cloudflared_arch="arm64" ;; \
arm) cloudflared_arch="arm" ;; \
armv7*|armv6*) cloudflared_arch="arm" ;; \
386|i386|i686) cloudflared_arch="386" ;; \
*) echo "unsupported cloudflared architecture: $arch" >&2; exit 1 ;; \
esac && \
if [ "$arch" = "arm" ] && [ -n "$variant" ] && [ "$variant" != "v7" ]; then \
echo "unsupported cloudflared ARM variant: $variant" >&2; exit 1; \
fi && \
curl -fsSL "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${cloudflared_arch}" -o /usr/local/bin/cloudflared && \
chmod +x /usr/local/bin/cloudflared && \
cloudflared version
# Create directories
RUN mkdir -p /app/db /app/logs /app/template && \
chmod 777 /app/db /app/logs /app/template
# Copy static files (frontend)
COPY static /app/static
# Copy the specific binary for the target architecture
# The workflow must ensure these files exist in the build context
COPY build /tmp/build
RUN arch="${TARGETARCH:-$(uname -m)}" && \
variant="${TARGETVARIANT:-}" && \
binary_arch="${arch}${variant}" && \
if [ "$arch" = "arm64" ]; then binary_arch="arm64"; fi && \
if [ "$arch" = "arm" ] && [ -z "$variant" ]; then binary_arch="armv7"; fi && \
if [ "$arch" = "386" ]; then binary_arch="x86"; fi && \
cp "/tmp/build/sublinkPro-linux-${binary_arch}" /app/sublinkPro && \
chmod +x /app/sublinkPro && \
rm -rf /tmp/build
EXPOSE 8000
CMD ["/app/sublinkPro"]