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.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #Build stage
  2. FROM docker.io/library/golang:1.20-alpine3.18 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 build-base git nodejs npm
  11. #Setup repo
  12. COPY . ${GOPATH}/src/code.gitea.io/gitea
  13. WORKDIR ${GOPATH}/src/code.gitea.io/gitea
  14. #Checkout version if set
  15. RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
  16. && make clean-all build
  17. # Begin env-to-ini build
  18. RUN go build contrib/environment-to-ini/environment-to-ini.go
  19. FROM docker.io/library/alpine:3.18
  20. LABEL maintainer="maintainers@gitea.io"
  21. EXPOSE 2222 3000
  22. RUN apk --no-cache add \
  23. bash \
  24. ca-certificates \
  25. dumb-init \
  26. gettext \
  27. git \
  28. curl \
  29. gnupg
  30. RUN addgroup \
  31. -S -g 1000 \
  32. git && \
  33. adduser \
  34. -S -H -D \
  35. -h /var/lib/gitea/git \
  36. -s /bin/bash \
  37. -u 1000 \
  38. -G git \
  39. git
  40. RUN mkdir -p /var/lib/gitea /etc/gitea
  41. RUN chown git:git /var/lib/gitea /etc/gitea
  42. COPY docker/rootless /
  43. COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
  44. COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
  45. COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
  46. RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-setup.sh /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
  47. RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh
  48. #git:git
  49. USER 1000:1000
  50. ENV GITEA_WORK_DIR /var/lib/gitea
  51. ENV GITEA_CUSTOM /var/lib/gitea/custom
  52. ENV GITEA_TEMP /tmp/gitea
  53. ENV TMPDIR /tmp/gitea
  54. #TODO add to docs the ability to define the ini to load (useful to test and revert a config)
  55. ENV GITEA_APP_INI /etc/gitea/app.ini
  56. ENV HOME "/var/lib/gitea/git"
  57. VOLUME ["/var/lib/gitea", "/etc/gitea"]
  58. WORKDIR /var/lib/gitea
  59. ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
  60. CMD []