1
1
# Build stage
2
- FROM docker.io/library/golang:1.21-alpine3.18 AS build-env
2
+ FROM docker.io/library/node:20-alpine3.18 AS build-frontend
3
+
4
+ ARG GITEA_VERSION
5
+
6
+ # Build deps
7
+ RUN apk --no-cache add \
8
+ build-base \
9
+ git \
10
+ && rm -rf /var/cache/apk/*
11
+
12
+ # Setup repo
13
+ WORKDIR /usr/src/code.gitea.io/gitea
14
+
15
+ COPY Makefile .
16
+
17
+ # Download NPM Packages
18
+ COPY package.json .
19
+ COPY package-lock.json .
20
+
21
+ RUN make deps-frontend
22
+
23
+ # Copy source files
24
+ COPY ./webpack.config.js .
25
+ COPY ./assets ./assets
26
+ COPY ./public ./public
27
+ COPY ./web_src ./web_src
28
+
29
+ # Checkout version if set
30
+ COPY ./.git ./.git
31
+ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}" ; fi
32
+
33
+ # Build frontend
34
+ RUN make clean-all frontend
35
+
36
+ # Build stage
37
+ FROM docker.io/library/golang:1.21-alpine3.18 AS build-backend
3
38
4
39
ARG GOPROXY
5
40
ENV GOPROXY ${GOPROXY:-direct}
@@ -13,8 +48,6 @@ ARG CGO_EXTRA_CFLAGS
13
48
RUN apk --no-cache add \
14
49
build-base \
15
50
git \
16
- nodejs \
17
- npm \
18
51
&& rm -rf /var/cache/apk/*
19
52
20
53
# Setup repo
@@ -28,19 +61,35 @@ COPY go.sum .
28
61
29
62
RUN make deps-backend
30
63
31
- # Download NPM Packages
32
- COPY package.json .
33
- COPY package-lock.json .
64
+ # Copy source files
65
+ COPY ./build ./build
66
+ COPY ./cmd ./cmd
67
+ COPY ./models ./models
68
+ COPY ./modules ./modules
69
+ COPY ./options ./options
70
+ COPY ./routers ./routers
71
+ COPY ./services ./services
72
+ COPY ./templates ./templates
73
+ COPY ./build.go .
74
+ COPY ./main.go .
34
75
35
- RUN make deps-frontend
76
+ # Checkout version if set
77
+ COPY ./.git ./.git
78
+ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}" ; fi
36
79
37
- COPY . .
80
+ # Clean directory
81
+ RUN make clean-all
38
82
39
- # Checkout version if set
40
- RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}" ; fi \
41
- && make clean-all build
83
+ # Copy frontend build artifacts
84
+ COPY --from=build-frontend /usr/src/code.gitea.io/gitea/public ./public
85
+
86
+ # Build backend
87
+ RUN make backend
42
88
43
89
# Begin env-to-ini build
90
+ COPY contrib/environment-to-ini/environment-to-ini.go contrib/environment-to-ini/environment-to-ini.go
91
+ COPY ./custom ./custom
92
+
44
93
RUN go build contrib/environment-to-ini/environment-to-ini.go
45
94
46
95
FROM docker.io/library/alpine:3.18 AS gitea-base
@@ -57,8 +106,11 @@ RUN apk --no-cache add \
57
106
58
107
RUN addgroup -S -g 1000 git
59
108
109
+ COPY --chmod=644 ./contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
110
+ COPY --chmod=755 --from=build-backend /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
111
+ COPY --chmod=755 --from=build-backend /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
112
+
60
113
FROM gitea-base AS gitea-rootless
61
- LABEL maintainer="maintainers@gitea.io"
62
114
63
115
EXPOSE 2222 3000
64
116
@@ -80,10 +132,6 @@ RUN chown git:git /var/lib/gitea /etc/gitea
80
132
# Copy local files
81
133
COPY --chmod=755 docker/rootless /
82
134
83
- COPY --from=build-env --chmod=755 --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
84
- COPY --from=build-env --chmod=755 --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
85
- COPY --from=build-env --chmod=644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
86
-
87
135
# git:git
88
136
USER 1000:1000
89
137
ENV GITEA_WORK_DIR /var/lib/gitea
@@ -101,7 +149,6 @@ ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
101
149
CMD []
102
150
103
151
FROM gitea-base AS gitea
104
- LABEL maintainer="maintainers@gitea.io"
105
152
106
153
EXPOSE 22 3000
107
154
@@ -131,7 +178,3 @@ ENTRYPOINT ["/usr/bin/entrypoint"]
131
178
CMD ["/bin/s6-svscan" , "/etc/s6" ]
132
179
133
180
COPY --chmod=755 docker/root /
134
-
135
- COPY --from=build-env --chmod=755 /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
136
- COPY --from=build-env --chmod=755 /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
137
- 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