ci/cd调整
This commit is contained in:
41
Dockerfile
41
Dockerfile
@@ -1,37 +1,24 @@
|
||||
FROM golang:1.26.0 AS builder
|
||||
# 阶段1: 构建
|
||||
FROM golang:alpine AS builder
|
||||
|
||||
RUN go env -w GO111MODULE=on
|
||||
RUN go env -w GOPROXY=https://goproxy.cn,direct
|
||||
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
|
||||
WORKDIR /build
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
COPY common ./common
|
||||
|
||||
RUN sed -i 's|replace gitea.com/red-future/common => ../common|replace gitea.com/red-future/common => ./common|' go.mod
|
||||
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
RUN go mod download && go mod tidy
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -v -o report-engine .
|
||||
RUN go build -ldflags="-s -w" -o main ./main.go
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
ENV TIME_ZONE=Asia/Seoul
|
||||
RUN apk add --no-cache tzdata ca-certificates && \
|
||||
ln -sf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime
|
||||
EXPOSE 3013
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /build/report-engine .
|
||||
COPY config.yml .
|
||||
|
||||
RUN mkdir -p resource/log/server
|
||||
|
||||
EXPOSE 3001
|
||||
|
||||
CMD ["./report-engine"]
|
||||
CMD ["./main"]
|
||||
|
||||
Reference in New Issue
Block a user