1
# ##############################################################################
3
# ##############################################################################
5
# #######################################
7
# #######################################
8
FROM golang:buster AS core-deps
10
WORKDIR /go/src/github.com/zitadel/zitadel
17
# #######################################
18
# compile custom protoc plugins
19
# #######################################
20
FROM golang:buster AS core-api-generator
22
WORKDIR /go/src/github.com/zitadel/zitadel
26
COPY internal/protoc internal/protoc
27
COPY pkg/grpc/protoc/v2 pkg/grpc/protoc/v2
29
RUN go install internal/protoc/protoc-gen-authoption/main.go \
30
&& mv $(go env GOPATH)/bin/main $(go env GOPATH)/bin/protoc-gen-authoption \
31
&& go install internal/protoc/protoc-gen-zitadel/main.go \
32
&& mv $(go env GOPATH)/bin/main $(go env GOPATH)/bin/protoc-gen-zitadel
34
# #######################################
36
# #######################################
37
FROM golang:buster AS core-api
39
WORKDIR /go/src/github.com/zitadel/zitadel
46
COPY --from=core-api-generator /go/bin /usr/local/bin
50
# #######################################
51
# generate code for login ui
52
# #######################################
53
FROM golang:buster AS core-login
55
WORKDIR /go/src/github.com/zitadel/zitadel
58
COPY internal/api/ui/login/static internal/api/ui/login/static
59
COPY internal/api/ui/login/statik internal/api/ui/login/statik
60
COPY internal/notification/static internal/notification/static
61
COPY internal/notification/statik internal/notification/statik
62
COPY internal/static internal/static
63
COPY internal/statik internal/statik
67
# #######################################
68
# generate code for assets
69
# #######################################
70
FROM golang:buster AS core-assets
71
WORKDIR /go/src/github.com/zitadel/zitadel
76
COPY internal/api/assets/generator internal/api/assets/generator
77
COPY internal/config internal/config
78
COPY internal/errors internal/errors
79
COPY --from=core-api /go/src/github.com/zitadel/zitadel/openapi/v2 openapi/v2
83
# #######################################
84
# Gather all core files
85
# #######################################
86
FROM core-deps AS core-gathered
95
COPY --from=core-api /go/src/github.com/zitadel/zitadel .
96
COPY --from=core-login /go/src/github.com/zitadel/zitadel .
97
COPY --from=core-assets /go/src/github.com/zitadel/zitadel/internal ./internal
99
# ##############################################################################
101
# ##############################################################################
103
# #######################################
104
# download console dependencies
105
# #######################################
106
FROM node:20-buster AS console-deps
108
WORKDIR /zitadel/console
110
COPY console/package.json .
111
COPY console/yarn.lock .
113
RUN yarn install --frozen-lockfile
115
# #######################################
116
# generate console client
117
# #######################################
118
FROM node:20-buster AS console-client
120
WORKDIR /zitadel/console
123
COPY --from=bufbuild/buf:latest /usr/local/bin/* /usr/local/bin/
124
ENV PATH="/usr/local/bin:${PATH}"
126
COPY console/package.json .
127
COPY console/buf.*.yaml .
132
# #######################################
133
# Gather all console files
134
# #######################################
135
FROM console-deps as console-gathered
137
COPY --from=console-client /zitadel/console/src/app/proto/generated src/app/proto/generated
140
COPY console/angular.json .
141
COPY console/ngsw-config.json .
142
COPY console/tsconfig* .
144
# #######################################
146
# #######################################
147
FROM console-gathered AS console
150
# ##############################################################################
151
# build the executable
152
# ##############################################################################
154
# #######################################
156
# #######################################
157
FROM core-gathered AS compile
162
COPY --from=console /zitadel/console/dist/console internal/api/ui/console/static/
164
RUN go build -o zitadel -ldflags="-s -w -race" \
167
ENTRYPOINT [ "./zitadel" ]
169
# #######################################
171
# #######################################
172
FROM scratch AS copy-executable
176
COPY --from=compile /go/src/github.com/zitadel/zitadel/zitadel /.artifacts/zitadel
178
# ##############################################################################
180
# ##############################################################################
181
FROM ubuntu/postgres:latest AS test-core-base
183
ARG DEBIAN_FRONTEND=noninteractive
185
RUN apt-get update && \
186
apt-get install -y --no-install-recommends \
192
update-ca-certificates; \
193
rm -rf /var/lib/apt/lists/*
196
COPY --from=golang:latest /usr/local/go/ /usr/local/go/
197
ENV PATH="/go/bin:/usr/local/go/bin:${PATH}"
199
WORKDIR /go/src/github.com/zitadel/zitadel
202
ENV DB_FLAVOR=postgres
203
ENV POSTGRES_USER=zitadel
204
ENV POSTGRES_DB=zitadel
205
ENV POSTGRES_PASSWORD=postgres
206
ENV POSTGRES_HOST_AUTH_METHOD=trust
209
ENV PGDATABASE=zitadel
210
ENV PGPASSWORD=postgres
215
COPY --from=core-deps /go/pkg/mod /root/go/pkg/mod
216
COPY --from=core-gathered /go/src/github.com/zitadel/zitadel .
218
# #######################################
220
# #######################################
221
FROM test-core-base AS test-core-unit
222
RUN go test -race -v -coverprofile=profile.cov ./...
224
# #######################################
226
# #######################################
227
FROM scratch AS coverage-core-unit
228
COPY --from=test-core-unit /go/src/github.com/zitadel/zitadel/profile.cov /coverage/
230
# #######################################
231
# integration test core
232
# #######################################
233
FROM test-core-base AS test-core-integration
234
ENV DB_FLAVOR=cockroach
237
COPY --from=cockroachdb/cockroach:latest /cockroach/cockroach /usr/local/bin/
238
ENV COCKROACH_BINARY=/cockroach/cockroach
240
ENV ZITADEL_MASTERKEY=MasterkeyNeedsToHave32Characters
242
COPY build/core-integration-test.sh /usr/local/bin/run-tests.sh
243
RUN chmod +x /usr/local/bin/run-tests.sh
247
# #######################################
249
# #######################################
250
FROM scratch AS coverage-core-integration
251
COPY --from=test-core-integration /go/src/github.com/zitadel/zitadel/profile.cov /coverage/
253
# ##############################################################################
255
# ##############################################################################
257
# #######################################
259
# #######################################
260
FROM bufbuild/buf:latest AS lint-api
267
# #######################################
269
# #######################################
270
FROM console-gathered AS lint-console
272
COPY console/.eslintrc.js .
273
COPY console/.prettier* .
276
# #######################################
278
# #######################################
279
FROM golangci/golangci-lint:latest AS lint-core
282
WORKDIR /go/src/github.com/zitadel/zitadel
286
COPY --from=core-deps /go/pkg/mod /go/pkg/mod
287
COPY --from=core-gathered /go/src/github.com/zitadel/zitadel .
289
RUN git fetch https://github.com/zitadel/zitadel main:main
291
RUN golangci-lint run \
293
--config ./.golangci.yaml \
294
--out-format=github-actions:report,colored-line-number \
295
--issues-exit-code=${LINT_EXIT_CODE} \
296
--concurrency=$(getconf _NPROCESSORS_ONLN)
298
# #######################################
300
# #######################################
301
FROM scratch AS lint-core-report
302
COPY --from=lint-core /go/src/github.com/zitadel/zitadel/report .