2026-03-18 10:19:42 +08:00
|
|
|
|
FROM golang:1.25.5-alpine AS builder
|
|
|
|
|
|
|
|
|
|
|
|
# 配置Alpine国内镜像源(加速apk)
|
|
|
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
|
|
|
|
|
&& apk add --no-cache git
|
|
|
|
|
|
|
|
|
|
|
|
ENV GO111MODULE=on
|
|
|
|
|
|
ENV GOPROXY=https://goproxy.cn,direct
|
|
|
|
|
|
ENV CGO_ENABLED=0
|
2026-03-18 10:40:33 +08:00
|
|
|
|
ENV GOTOOLCHAIN=auto
|
|
|
|
|
|
ENV GOPRIVATE=gitea.com/red-future/common
|
2026-03-18 10:19:42 +08:00
|
|
|
|
|
2026-03-18 10:40:33 +08:00
|
|
|
|
# 配置git使用私有Gitea仓库
|
2026-04-01 11:21:44 +08:00
|
|
|
|
RUN git config --global url."http://x-token-auth:9b31146aa8c10a7cb4f2e49dcee0934a223be1076289810e1ad98b968066c2bc@116.204.74.41:3000/red-future/common.git".insteadOf "https://gitea.com/red-future/common.git" && \
|
2026-03-18 10:40:33 +08:00
|
|
|
|
git config --global credential.helper store
|
|
|
|
|
|
|
|
|
|
|
|
# 设置GIT凭据
|
2026-04-01 11:21:44 +08:00
|
|
|
|
RUN echo "http://x-token-auth:9b31146aa8c10a7cb4f2e49dcee0934a223be1076289810e1ad98b968066c2bc@116.204.74.41:3000" > ~/.git-credentials
|
2026-03-18 10:19:42 +08:00
|
|
|
|
|
|
|
|
|
|
WORKDIR /build
|
|
|
|
|
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
RUN go mod tidy && go mod download
|
|
|
|
|
|
|
|
|
|
|
|
RUN go build -ldflags="-s -w" -o main ./main.go
|
|
|
|
|
|
|
|
|
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
|
|
|
|
# 配置Alpine国内镜像源(加速apk)
|
|
|
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
|
|
|
|
|
&& apk add --no-cache tzdata \
|
|
|
|
|
|
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
|
|
|
|
|
&& echo Asia/Shanghai > /etc/timezone
|
|
|
|
|
|
|
|
|
|
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
COPY --from=builder /build/main .
|
|
|
|
|
|
COPY --from=builder /build/manifest/config/config.yaml ./manifest/config/config.yaml
|
|
|
|
|
|
COPY --from=builder /build/resource ./resource
|
|
|
|
|
|
|
|
|
|
|
|
RUN mkdir -p /app/resource/log/run \
|
|
|
|
|
|
&& mkdir -p /app/resource/log/server \
|
|
|
|
|
|
&& adduser -D -u 1000 appuser \
|
|
|
|
|
|
&& chown -R appuser:appuser /app
|
|
|
|
|
|
|
|
|
|
|
|
USER appuser
|
|
|
|
|
|
|
|
|
|
|
|
EXPOSE 8808
|
|
|
|
|
|
|
2026-03-18 10:40:33 +08:00
|
|
|
|
CMD ["./main"]
|