ci/cd调整
This commit is contained in:
42
Dockerfile
42
Dockerfile
@@ -1,18 +1,42 @@
|
|||||||
# 最小化Docker镜像
|
# 阶段1: 构建
|
||||||
FROM busybox:uclibc
|
FROM golang:alpine AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache git ca-certificates tzdata
|
||||||
|
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
ENV GO111MODULE=on
|
||||||
|
ENV GOPROXY=https://goproxy.cn,direct
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
ENV GOTOOLCHAIN=auto
|
||||||
|
ENV GOPRIVATE=gitea.com/red-future/common
|
||||||
|
|
||||||
|
# 配置git使用私有Gitea仓库
|
||||||
|
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" && \
|
||||||
|
git config --global credential.helper store
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go mod download && go mod tidy
|
||||||
|
|
||||||
|
RUN go build -ldflags="-s -w" -o main ./main.go
|
||||||
|
|
||||||
|
# 阶段2: 运行
|
||||||
|
FROM alpine:3.19
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
|
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 复制时区数据
|
|
||||||
COPY timezone/localtime /etc/localtime
|
|
||||||
COPY timezone/timezone /etc/timezone
|
|
||||||
COPY timezone/Shanghai /usr/share/zoneinfo/Asia/Shanghai
|
|
||||||
|
|
||||||
# 复制预构建的二进制文件和配置文件
|
# 复制预构建的二进制文件和配置文件
|
||||||
COPY app ./main
|
COPY app ./main
|
||||||
COPY manifest/config/config.yaml ./manifest/config/config.yaml
|
COPY manifest/config/config.yaml ./manifest/config/config.yaml
|
||||||
COPY manifest/config/config-dev.yaml ./manifest/config/config-dev.yaml
|
|
||||||
COPY manifest/config/config-master.yaml ./manifest/config/config-master.yaml
|
|
||||||
COPY resource ./resource
|
COPY resource ./resource
|
||||||
|
|
||||||
# 创建日志目录
|
# 创建日志目录
|
||||||
|
|||||||
Reference in New Issue
Block a user