FROM golang:alpine as golang
RUN mkdir -p /root/auth
RUN mkdir -p /root/auth/output
COPY ./ /root/auth
WORKDIR /root/auth/output
RUN go build /root/auth/cmd/main.go
FROM alpine as alpine
RUN mkdir -p /root/auth
COPY --from=golang --chown=root:root /root/auth/output /root/auth
CMD /root/auth/main
然后build镜像
docker build -t libaibai/lizhe-auth:v0.1 .
docker run -i -t --name test -p 3080:3080 libaibai/lizhe-auth:v0.1