You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Dockerfile.rootless 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Build stage
  2. FROM docker.io/library/golang:1.22-alpine3.19 AS build-env
  3. ARG GOPROXY
  4. ENV GOPROXY ${GOPROXY:-direct}
  5. ARG GITEA_VERSION
  6. ARG TAGS="sqlite sqlite_unlock_notify"
  7. ENV TAGS "bindata timetzdata $TAGS"
  8. ARG CGO_EXTRA_CFLAGS
  9. #Build deps
  10. RUN apk --no-cache add \
  11. build-base \
  12. git \
  13. nodejs \
  14. npm \
  15. && rm -rf /var/cache/apk/*
  16. # Setup repo
  17. COPY . ${GOPATH}/src/code.gitea.io/gitea
  18. WORKDIR ${GOPATH}/src/code.gitea.io/gitea
  19. # Checkout version if set
  20. RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
  21. && make clean-all build
  22. # Begin env-to-ini build
  23. RUN go build contrib/environment-to-ini/environment-to-ini.go
  24. # Copy local files
  25. COPY docker/rootless /tmp/local
  26. # Set permissions
  27. RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
  28. /tmp/local/usr/local/bin/docker-setup.sh \
  29. /tmp/local/usr/local/bin/gitea \
  30. /go/src/code.gitea.io/gitea/gitea \
  31. /go/src/code.gitea.io/gitea/environment-to-ini
  32. RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
  33. FROM docker.io/library/alpine:3.19
  34. LABEL maintainer="maintainers@gitea.io"
  35. EXPOSE 2222 3000
  36. RUN apk --no-cache add \
  37. bash \
  38. ca-certificates \
  39. dumb-init \
  40. gettext \
  41. git \
  42. curl \
  43. gnupg \
  44. && rm -rf /var/cache/apk/*
  45. RUN addgroup \
  46. -S -g 1000 \
  47. git && \
  48. adduser \
  49. -S -H -D \
  50. -h /var/lib/gitea/git \
  51. -s /bin/bash \
  52. -u 1000 \
  53. -G git \
  54. git
  55. RUN mkdir -p /var/lib/gitea /etc/gitea
  56. RUN chown git:git /var/lib/gitea /etc/gitea
  57. COPY --from=build-env /tmp/local /
  58. COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
  59. COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
  60. COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
  61. # git:git
  62. USER 1000:1000
  63. ENV GITEA_WORK_DIR /var/lib/gitea
  64. ENV GITEA_CUSTOM /var/lib/gitea/custom
  65. ENV GITEA_TEMP /tmp/gitea
  66. ENV TMPDIR /tmp/gitea
  67. # TODO add to docs the ability to define the ini to load (useful to test and revert a config)
  68. ENV GITEA_APP_INI /etc/gitea/app.ini
  69. ENV HOME "/var/lib/gitea/git"
  70. VOLUME ["/var/lib/gitea", "/etc/gitea"]
  71. WORKDIR /var/lib/gitea
  72. ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
  73. CMD []