-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
54 lines (39 loc) · 1.3 KB
/
Dockerfile
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
FROM --platform=$BUILDPLATFORM golang:1.22 as builder
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG PREFETCHED
ENV CGO_ENABLED 1
ENV GOOS linux
ENV DEBIAN_FRONTEND noninteractive
WORKDIR /app
RUN apt update && \
apt install -y ca-certificates openssl tzdata wget unzip gcc musl-dev make && \
update-ca-certificates && \
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
apt install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu; \
fi
COPY . .
# Download frontend dependencies if not cached
RUN if [ -z "$PREFETCHED" ]; then \
make frontend; \
fi
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
make build-production BINARY=server; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
GOARCH=arm64 CC=aarch64-linux-gnu-gcc make build-production BINARY=server; \
else \
echo "Unsupported platform: $TARGETPLATFORM"; \
exit 1; \
fi
FROM scratch
WORKDIR /app
ENV GIN_MODE release
ENV TZ Asia/Shanghai
EXPOSE 14444
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/bin/server /app/server
VOLUME ["/app/data/"]
ENTRYPOINT ["/app/server"]