Dockerfilebak 646 B

12345678910111213141516171819202122232425262728
  1. FROM golang:alpine as builder
  2. MAINTAINER lwnmengjing
  3. ENV GOPROXY https://goproxy.cn/
  4. WORKDIR /go/release
  5. #RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
  6. RUN apk update && apk add tzdata
  7. COPY go.mod ./go.mod
  8. RUN go mod tidy
  9. COPY . .
  10. RUN pwd && ls
  11. RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o go-admin .
  12. FROM alpine
  13. COPY --from=builder /go/release/go-admin /
  14. COPY --from=builder /go/release/config/settings.yml /config/settings.yml
  15. COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  16. EXPOSE 8000
  17. CMD ["/go-admin","server","-c", "/config/settings.yml"]