1
0

Dockerfile.next 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. FROM golang:alpine3.23 AS binarybuilder
  2. RUN apk --no-cache --no-progress add --virtual \
  3. build-deps \
  4. build-base \
  5. git \
  6. linux-pam-dev
  7. WORKDIR /gogs.io/gogs
  8. COPY . .
  9. RUN ./docker/build/install-task.sh
  10. RUN TAGS="cert pam" task build
  11. FROM alpine:3.23
  12. # Create git user and group with fixed UID/GID at build time for better K8s security context support.
  13. # Using 1000:1000 as it's a common non-root UID/GID that works well with most volume permission setups.
  14. ARG GOGS_UID=1000
  15. ARG GOGS_GID=1000
  16. RUN addgroup -g ${GOGS_GID} -S git && \
  17. adduser -u ${GOGS_UID} -G git -H -D -g 'Gogs Git User' -h /data/git -s /bin/sh git
  18. RUN apk --no-cache --no-progress add \
  19. bash \
  20. ca-certificates \
  21. curl \
  22. git \
  23. linux-pam \
  24. openssh-keygen
  25. ENV GOGS_CUSTOM=/data/gogs
  26. WORKDIR /app/gogs
  27. COPY --from=binarybuilder /gogs.io/gogs/.bin/gogs .
  28. COPY docker-next/start.sh .
  29. RUN chmod +x start.sh && \
  30. mkdir -p /data && \
  31. ln -s /data/git /home/git && \
  32. chown -R git:git /app/gogs /data
  33. # Configure Docker Container
  34. VOLUME ["/data", "/backup"]
  35. EXPOSE 22 3000
  36. HEALTHCHECK CMD (curl --noproxy localhost -o /dev/null -sS http://localhost:3000/healthcheck) || exit 1
  37. # Run as non-root user by default for better K8s security context support.
  38. USER git:git
  39. ENTRYPOINT ["/app/gogs/start.sh"]
  40. CMD ["/app/gogs/gogs", "web"]