Dockerfile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. FROM golang:alpine3.17 AS binarybuilder
  2. # Set goproxy
  3. RUN go env -w GO111MODULE=on
  4. RUN go env -w GOPROXY=https://goproxy.cn,direct
  5. # Set mirror
  6. RUN echo "https://mirrors.sustech.edu.cn/alpine/v3.16/main" > /etc/apk/repositories ; \
  7. echo "https://mirrors.sustech.edu.cn/alpine/v3.16/community" >> /etc/apk/repositories ;
  8. RUN apk --no-cache --no-progress add --virtual \
  9. build-deps \
  10. build-base \
  11. git \
  12. linux-pam-dev
  13. WORKDIR /gogs.io/gogs
  14. COPY . .
  15. RUN ./docker/build/install-task.sh
  16. RUN TAGS="cert pam" task build
  17. FROM alpine:3.17
  18. # Set mirror
  19. RUN echo "https://mirrors.sustech.edu.cn/alpine/v3.16/main" > /etc/apk/repositories ; \
  20. echo "https://mirrors.sustech.edu.cn/alpine/v3.16/community" >> /etc/apk/repositories ;
  21. RUN apk --no-cache --no-progress add \
  22. bash \
  23. ca-certificates \
  24. curl \
  25. git \
  26. linux-pam \
  27. openssh \
  28. s6 \
  29. shadow \
  30. socat \
  31. tzdata \
  32. rsync
  33. ENV GOGS_CUSTOM /data/gogs
  34. # Configure LibC Name Service
  35. COPY docker/nsswitch.conf /etc/nsswitch.conf
  36. WORKDIR /app/gogs
  37. COPY docker ./docker
  38. COPY --from=binarybuilder /gogs.io/gogs/gogs .
  39. RUN ./docker/build/finalize.sh
  40. # Configure Docker Container
  41. VOLUME ["/data", "/backup"]
  42. EXPOSE 22 3000
  43. HEALTHCHECK CMD (curl -o /dev/null -sS http://localhost:3000/healthcheck) || exit 1
  44. ENTRYPOINT ["/app/gogs/docker/start.sh"]
  45. CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"]