#docker build -t skintestgo --build-arg PROJECT=test . FROM golang:1.17 as builder ARG PROJECT # Create app directory RUN mkdir /app # Add file to /app/ ADD . /app/ # Build the binary WORKDIR /app/${PROJECT} RUN go env -w GOPROXY=https://goproxy.cn && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ${PROJECT}.go # Run service on container startup FROM registry.cn-zhangjiakou.aliyuncs.com/fenn/alpine_cn_go:1.0.1 ARG PROJECT WORKDIR /app/${PROJECT} RUN mkdir etc RUN mkdir -p runtime/upload COPY --from=builder /app/${PROJECT}/etc/${PROJECT}-api-prod.yaml /app/${PROJECT}/etc/${PROJECT}-api.yaml COPY --from=builder /app/${PROJECT}/main /app/${PROJECT}/ WORKDIR /app/${PROJECT}/ CMD ["./main"]