chore: refactor Dockerfiles to improve module management and build process by adding workspace support and restructuring source code copying

This commit is contained in:
keven1024
2026-03-01 23:55:27 +08:00
parent 75c269b60e
commit f9251663a2
2 changed files with 19 additions and 9 deletions

View File

@@ -12,7 +12,14 @@ RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct && g
# Copy the source code. Note the slash at the end, as explained in
# https://docs.docker.com/engine/reference/builder/#copy
COPY . .
COPY go.work go.work.sum ./
COPY worker/ ./worker/
COPY pkg/ ./pkg/
RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct && \
(cd worker && go mod download) && \
(cd pkg/utils && go mod download) && \
(cd pkg/models && go mod download) && \
(cd pkg/services && go mod download)
# Build
RUN CGO_ENABLED=0 GOOS=linux go build -o worker