@@ -18,59 +18,104 @@ RUN apk --no-cache add \
1818 && rm -rf /var/cache/apk/*
1919
2020# Setup repo
21- COPY . ${GOPATH}/src/code.gitea.io/gitea
2221WORKDIR ${GOPATH}/src/code.gitea.io/gitea
2322
23+ COPY ./go.mod .
24+
25+ RUN go mod download
26+
27+ COPY package.json .
28+ COPY package-lock.json .
29+
30+ RUN npm install --no-save --verbose
31+
32+ COPY . .
33+
2434# Checkout version if set
2535RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}" ; fi \
2636 && make clean-all build
2737
2838# Begin env-to-ini build
2939RUN go build contrib/environment-to-ini/environment-to-ini.go
3040
31- # Copy local files
32- COPY docker/root /tmp/local
33-
34- # Set permissions
35- RUN chmod 755 /tmp/local/usr/bin/entrypoint \
36- /tmp/local/usr/local/bin/gitea \
37- /tmp/local/etc/s6/gitea/* \
38- /tmp/local/etc/s6/openssh/* \
39- /tmp/local/etc/s6/.s6-svscan/* \
40- /go/src/code.gitea.io/gitea/gitea \
41- /go/src/code.gitea.io/gitea/environment-to-ini
42- RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
43-
44- FROM docker.io/library/alpine:3.18
41+ FROM docker.io/library/alpine:3.18 AS gitea-base
4542LABEL maintainer=
"[email protected] " 4643
47- EXPOSE 22 3000
48-
4944RUN apk --no-cache add \
5045 bash \
5146 ca-certificates \
52- curl \
5347 gettext \
5448 git \
49+ curl \
50+ gnupg \
51+ && rm -rf /var/cache/apk/*
52+
53+ RUN addgroup -S -g 1000 git
54+
55+ FROM gitea-base AS gitea-rootless
56+ LABEL maintainer=
"[email protected] " 57+
58+ EXPOSE 2222 3000
59+
60+ RUN apk --no-cache add \
61+ dumb-init \
62+ && rm -rf /var/cache/apk/*
63+
64+ RUN adduser \
65+ -S -H -D \
66+ -h /var/lib/gitea/git \
67+ -s /bin/bash \
68+ -u 1000 \
69+ -G git \
70+ git
71+
72+ RUN mkdir -p /var/lib/gitea /etc/gitea
73+ RUN chown git:git /var/lib/gitea /etc/gitea
74+
75+ # Copy local files
76+ COPY --chmod=755 docker/rootless /tmp/local
77+
78+ COPY --from=build-env --chmod=755 --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
79+ COPY --from=build-env --chmod=755 --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
80+ COPY --from=build-env --chmod=644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
81+
82+ # git:git
83+ USER 1000:1000
84+ ENV GITEA_WORK_DIR /var/lib/gitea
85+ ENV GITEA_CUSTOM /var/lib/gitea/custom
86+ ENV GITEA_TEMP /tmp/gitea
87+ ENV TMPDIR /tmp/gitea
88+
89+ # TODO add to docs the ability to define the ini to load (useful to test and revert a config)
90+ ENV GITEA_APP_INI /etc/gitea/app.ini
91+ ENV HOME "/var/lib/gitea/git"
92+ VOLUME ["/var/lib/gitea" , "/etc/gitea" ]
93+ WORKDIR /var/lib/gitea
94+
95+ ENTRYPOINT ["/usr/bin/dumb-init" , "--" , "/usr/local/bin/docker-entrypoint.sh" ]
96+ CMD []
97+
98+ FROM gitea-base AS gitea
99+ LABEL maintainer=
"[email protected] " 100+
101+ EXPOSE 22 3000
102+
103+ RUN apk --no-cache add \
55104 linux-pam \
56105 openssh \
57106 s6 \
58107 sqlite \
59108 su-exec \
60- gnupg \
61109 && rm -rf /var/cache/apk/*
62110
63- RUN addgroup \
64- -S -g 1000 \
65- git && \
66- adduser \
111+ RUN adduser \
67112 -S -H -D \
68113 -h /data/git \
69114 -s /bin/bash \
70115 -u 1000 \
71116 -G git \
72117 git && \
73- echo "git:*" | chpasswd -e
118+ echo "git:*" | chpasswd -e
74119
75120ENV USER git
76121ENV GITEA_CUSTOM /data/gitea
@@ -80,7 +125,8 @@ VOLUME ["/data"]
80125ENTRYPOINT ["/usr/bin/entrypoint" ]
81126CMD ["/bin/s6-svscan" , "/etc/s6" ]
82127
83- COPY --from=build-env /tmp/local /
84- COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
85- COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
86- COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
128+ COPY --chmod=755 docker/root /tmp/local
129+
130+ COPY --from=build-env --chmod=755 /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
131+ COPY --from=build-env --chmod=755 /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
132+ COPY --from=build-env --chmod=644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
0 commit comments