update dockerfile

This commit is contained in:
kenneth 2025-06-12 10:37:16 +08:00
parent b71e718308
commit 8bdf9e9b57

View File

@ -1,16 +1,23 @@
# Build Stage
FROM golang:1.24.0-alpine3.21 AS builder
# Modules Stage
FROM golang:1.24.4-alpine3.22 AS modules
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct
COPY go.mod go.sum /modules/
WORKDIR /modules
RUN go mod download
# Build Stage
FROM golang:1.24.4-alpine3.22 AS builder
COPY --from=modules /go/pkg /go/pkg
WORKDIR /app
COPY ../.. .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o testpaper main.go
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o management main.go
# Run Stage
FROM zc1185230223/alpine:3.21
FROM zc1185230223/alpine:3.22
WORKDIR /app
COPY --from=builder /app/testpaper .
COPY --from=builder /app/management .
RUN touch config.yaml
EXPOSE 15001
CMD ["/app/testpaper", "api", "-c", "config.yaml"]
CMD ["/app/management", "erp", "-c", "config.yaml"]