1 回答

TA贡献1966条经验 获得超4个赞
定义函数的文件main()位于cmd/app. 不是将当前工作目录更改为cmd/app,而是附加cmd/app/main.go到go build命令。
你Dockerfile看起来像这样:
# golang image where workspace (GOPATH) configured at /go.
FROM golang:alpine as builder
ADD . /go/src/frontend-microservice
WORKDIR /go/src/frontend-microservice
RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /frontend-microservice cmd/app/main.go
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /frontend-microservice ./frontend-microservice
RUN mkdir ./configs
COPY ./configs/config.json ./configs
EXPOSE 8080
ENTRYPOINT ["./frontend-microservice"]
- 1 回答
- 0 关注
- 151 浏览
添加回答
举报