-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile-User
More file actions
48 lines (34 loc) · 1.08 KB
/
Dockerfile-User
File metadata and controls
48 lines (34 loc) · 1.08 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
FROM golang:1.24.4-alpine AS builder
WORKDIR /app
ENV GOPROXY=https://goproxy.cn,direct
ENV GOSUMDB=off
ENV GOPRIVATE=*
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
RUN apk add --no-cache git ca-certificates tzdata openssl && \
git config --global http.sslverify false && \
git config --global http.postBuffer 1048576000
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
GOPROXY=https://goproxy.cn,direct \
GOSUMDB=off \
go mod download
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build \
-ldflags="-w -s" \
-o /app/bin/service \
./app/user
RUN mkdir -p /app/config && \
if [ -d "./app/user/etc" ]; then \
cp -r ./app/user/etc/userrpc.yaml /app/config/config.yaml 2>/dev/null || true; \
fi
FROM alpine:latest
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/bin/service /service
COPY --from=builder /app/config /etc/
EXPOSE 9001
EXPOSE 9091
CMD ["/service", "-f", "/etc/config.yaml"]