Dockerfile 927 B

123456789101112131415161718192021222324252627282930313233
  1. FROM golang:1.19-alpine as build
  2. WORKDIR /app/kpt-pasture
  3. COPY . .
  4. RUN mkdir -p ./bin
  5. RUN go env -w GO111MODULE=on && \
  6. go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct && \
  7. go env -w CGO_ENABLED=0 && \
  8. go env -w GOARCH=amd64 && \
  9. go env -w GOOS=linux && \
  10. go build -o ./kptPasture -ldflags "-X kpt.kptyun.cn:3000/kpt-event/kpt-pasture/pod.appVersion=beef" main.go
  11. FROM alpine:latest
  12. LABEL name="kpt-pasture" \
  13. description="pt service" \
  14. owner="yiping.xu"
  15. WORKDIR /app/kpt-pasture
  16. RUN rm -f /etc/localtime \
  17. && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  18. && echo "Asia/Shanghai" > /etc/timezone
  19. COPY --from=0 /app/kpt-pasture/config/ /app/kpt-pasture/config/
  20. COPY --from=0 /app/kpt-pasture/kptPasture /app/kpt-pasture/kptPasture
  21. EXPOSE 8090
  22. VOLUME ["/app/kpt-pasture/logger","/app/kpt-pasture/config","/app/kpt-pasture/files"]
  23. CMD ["/app/kpt-pasture/kptPasture","http"]