DockerfileGithubAction 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. FROM golang:alpine as serverbuild
  2. WORKDIR /work
  3. COPY server .
  4. RUN apk update && apk add git
  5. RUN go build -ldflags "-s -w -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S)'" -o pmail main.go
  6. RUN cd /work/hooks/telegram_push && go build -ldflags "-s -W" -o output/telegram_push main.go
  7. RUN cd /work/hooks/web_push && go build -ldflags "-s -W" -o output/web_push main.go
  8. RUN cd /work/hooks/wechat_push && go build -ldflags "-s -W" -o output/wechat_push main.go
  9. FROM alpine
  10. WORKDIR /work
  11. # 设置时区
  12. RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
  13. RUN apk add --no-cache tzdata \
  14. && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  15. && echo "Asia/Shanghai" > /etc/timezone \
  16. &&rm -rf /var/cache/apk/* /tmp/* /var/tmp/* $HOME/.cache
  17. COPY --from=serverbuild /work/pmail .
  18. COPY --from=serverbuild /work/hooks/telegram_push/output/* ./plugin/
  19. COPY --from=serverbuild /work/hooks/web_push/output/* ./plugin/
  20. COPY --from=serverbuild /work/hooks/wechat_push/output/* ./plugin/
  21. CMD /work/pmail