Dockerfile 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. WORKDIR /app
  5. ARG APP_ENV
  6. ARG APP_CONF
  7. ENV APP_ENV=${APP_ENV:?err}
  8. ENV APP_CONF=${APP_CONF:?err}
  9. COPY . /app
  10. COPY ${APP_CONF} /app/websocket.yaml
  11. RUN export GOPROXY=https://goproxy.cn,direct && \
  12. go mod tidy && \
  13. go build -ldflags="-s -w" -o /app/websocket
  14. FROM ${REGISTRY}/alpine:3.16
  15. RUN set -eux && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
  16. RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  17. && echo "Asia/Shanghai" > /etc/timezone \
  18. && apk del tzdata
  19. WORKDIR /app
  20. COPY --from=builder /app /app
  21. # EXPOSE ${HTTP_PROT}
  22. ENTRYPOINT [ "./websocket", "-f", "websocket.yaml" ]
  23. # ENTRYPOINT [ "top" ]
  24. #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/... .
  25. #docker run -it --rm --entrypoint=ash 1.1.1.1:5000/demo-api:v1