46 lines
1.1 KiB
Docker
46 lines
1.1 KiB
Docker
|
|
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
|
|||
|
|
ENV GOPRIVATE=gitee.com/red-future---jilin-g/*
|
|||
|
|
|
|||
|
|
ARG GITEE_TOKEN
|
|||
|
|
RUN git config --global url."https://oauth2:cf5eb6b356c7040747eb5eda8b48a617@gitee.com/".insteadOf "https://gitee.com/"
|
|||
|
|
|
|||
|
|
WORKDIR /build
|
|||
|
|
|
|||
|
|
COPY ../../../../../Downloads/未命名文件夹 .
|
|||
|
|
|
|||
|
|
# 强制更新 common 包到 master 最新版本
|
|||
|
|
RUN go get -u gitee.com/red-future---jilin-g/common@master
|
|||
|
|
|
|||
|
|
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
|
|||
|
|
|
|||
|
|
ENV TZ=Asia/Shanghai
|
|||
|
|
RUN apk add --no-cache tzdata \
|
|||
|
|
&& ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
|
|||
|
|
&& echo $TZ > /etc/timezone
|
|||
|
|
|
|||
|
|
WORKDIR /app
|
|||
|
|
|
|||
|
|
COPY --from=builder /build/main .
|
|||
|
|
COPY --from=builder /build/config.yml .
|
|||
|
|
|
|||
|
|
RUN adduser -D -u 1000 appuser
|
|||
|
|
USER appuser
|
|||
|
|
|
|||
|
|
EXPOSE 8000
|
|||
|
|
|
|||
|
|
CMD ["./main"]
|