Dockerfile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ARG REGISTRY=docker.io
  2. FROM ${REGISTRY}/golang:1.22.1-alpine3.19 AS builder
  3. RUN set -eux && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
  4. ARG APP_RELATIVE_PATH
  5. # ARG HTTP_PROT
  6. WORKDIR /app
  7. COPY . /app
  8. # RUN rm -rf /app/bin/
  9. # RUN export GOPROXY=https://goproxy.cn,direct && go mod tidy
  10. # RUN go build -ldflags="-s -w" -o ./bin/server ${APP_RELATIVE_PATH}
  11. RUN export GOPROXY=https://goproxy.cn,direct && \
  12. go mod tidy && \
  13. go build -ldflags="-s -w" -o /app
  14. # ENTRYPOINT ["top"]
  15. FROM ${REGISTRY}/alpine:3.16
  16. RUN set -eux && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
  17. RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  18. && echo "Asia/Shanghai" > /etc/timezone \
  19. && apk del tzdata
  20. # ARG HTTP_PROT
  21. ARG APP_ENV
  22. ENV APP_ENV=${APP_ENV}
  23. # ENV HTTP_PROT=${HTTP_PROT}
  24. WORKDIR /app
  25. COPY --from=builder /app /app
  26. # EXPOSE ${HTTP_PROT}
  27. ENTRYPOINT [ "./websocket" ]
  28. # ENTRYPOINT [ "top" ]
  29. #docker build -t 1.1.1.1:5000/demo-api:v1 --build-arg APP_CONF=config/prod.yml --build-arg APP_RELATIVE_PATH=./cmd/server/... .
  30. #docker run -it --rm --entrypoint=ash 1.1.1.1:5000/demo-api:v1