not nice but running

This commit is contained in:
Florian Forster 2025-02-19 01:02:12 +01:00
parent a203b85a59
commit 7d28887cd2
5 changed files with 162 additions and 113 deletions

View File

@ -1,58 +0,0 @@
ARG NODE_VERSION=22
ARG GO_VERSION=1.23
## Console
FROM node:${NODE_VERSION} AS console-base
WORKDIR /app
COPY console/package.json console/yarn.lock console/buf.gen.yaml ./
COPY proto/ ../proto/
RUN yarn install && yarn generate
COPY console/ .
COPY docs/frameworks.json ../docs/frameworks.json
FROM console-base AS console-build
RUN yarn build
FROM console-base AS console-lint
RUN yarn lint
FROM nginx:stable-alpine AS console-image
RUN rm -rf /usr/share/nginx/html/*
COPY .build/console/nginx.conf /etc/nginx/nginx.conf
COPY --from=console-build /app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
FROM scratch AS console-output
COPY --from=console-build /app/dist/console .
## Core
FROM golang:${GO_VERSION} AS core-base
ARG SASS_VERSION=1.64.1
ARG GOLANG_CI_VERSION=1.64.5
RUN apt-get update && apt-get install -y npm && npm install -g sass@${SASS_VERSION}
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANG_CI_VERSION}
WORKDIR /app
COPY go.mod go.sum Makefile buf.gen.yaml buf.work.yaml main.go .golangci.yaml ./
COPY .git/ .git/
COPY cmd/ cmd/
COPY internal/ internal/
COPY openapi/ openapi/
COPY pkg/ pkg/
COPY proto/ proto/
COPY statik/ statik/
COPY --from=console-build /app/dist/console internal/api/ui/console/static
RUN make core_build
FROM core-base AS core-build
RUN make compile
FROM core-base AS core-lint
RUN make core_lint
FROM scratch AS core-output
COPY --from=core-build /app/zitadel .
FROM core-base AS core-image
FROM core-base AS core-unit-test
RUN make core_unit_test

22
Dockerfile.console Normal file
View File

@ -0,0 +1,22 @@
FROM node AS base
WORKDIR /app
COPY console/package.json console/yarn.lock console/buf.gen.yaml ./
COPY proto/ ../proto/
RUN yarn install && yarn generate
COPY console/ .
COPY docs/frameworks.json ../docs/frameworks.json
FROM base AS build
RUN yarn build
FROM base AS lint
RUN yarn lint
FROM nginx AS image
RUN rm -rf /usr/share/nginx/html/*
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
FROM scratch AS output
COPY --from=build /app/dist/console .

54
Dockerfile.core Normal file
View File

@ -0,0 +1,54 @@
FROM golang AS base
ARG SASS_VERSION=
ARG GOLANG_CI_VERSION=
RUN apt-get update && apt-get install -y npm && npm install -g sass@${SASS_VERSION}
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANG_CI_VERSION}
WORKDIR /app
COPY go.mod go.sum Makefile buf.gen.yaml buf.work.yaml main.go .golangci.yaml ./
COPY .git/ .git/
COPY cmd/ cmd/
COPY internal/ internal/
COPY openapi/ openapi/
COPY pkg/ pkg/
COPY proto/ proto/
COPY statik/ statik/
COPY --from=console ./ internal/api/ui/console/static
RUN make core_build
FROM base AS build
RUN make compile_pipeline
RUN ls -la && pwd
FROM base AS lint
RUN make core_lint
FROM scratch AS output
COPY --from=build /app/zitadel .
FROM base AS unit-test
RUN make core_unit_test
FROM debian:latest AS base-image
ENV ZITADEL_ARGS=
ARG TARGETPLATFORM
RUN apt-get update && apt-get install ca-certificates -y
COPY build/entrypoint.sh /app/entrypoint.sh
COPY --from=build /app/zitadel /app/zitadel
RUN useradd -s "" --home / zitadel && \
chown zitadel /app/zitadel && \
chmod +x /app/zitadel && \
chown zitadel /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh
WORKDIR /app
ENV PATH="/app:${PATH}"
USER zitadel
ENTRYPOINT ["/app/entrypoint.sh"]
FROM scratch AS image
ARG TARGETPLATFORM
COPY --from=base-image /etc/passwd /etc/passwd
COPY --from=base-image /etc/ssl/certs /etc/ssl/certs
COPY --from=base-image /app/zitadel /app/zitadel
HEALTHCHECK NONE
USER zitadel
ENTRYPOINT ["/app/zitadel"]

View File

@ -3,11 +3,7 @@ variable "GITHUB_SHA" {
}
variable "REGISTRY" {
default = "ghcr.io/fforootd"
}
group "generate" {
targets = ["console-base", "core-base"]
default = "ghcr.io/zitadel"
}
group "build" {
@ -18,62 +14,70 @@ group "output" {
targets = ["console-output", "core-output"]
}
group "unit-test" {
targets = ["core-unit-test"]
group "image" {
targets = ["console-image", "core-image"]
}
group "lint" {
targets = ["console-lint", "core-lint"]
target "_console" {
dockerfile = "Dockerfile.console"
context = "."
contexts = {
node = "docker-image://node:22"
nginx = "docker-image://nginx:1.27-alpine"
}
}
target "console-base" {
target = "console-base"
target "console" {
name = "console-${tgt}"
inherits = ["_console"]
matrix = {
tgt = ["build", "output", "lint", "image"]
}
output = {
"build" = ["type=cacheonly"]
"output" = ["type=local,dest=.build/console"]
"lint" = ["type=cacheonly"]
"image" = ["type=docker"]
}[tgt]
tags = {
"build" = []
"output" = []
"lint" = []
"image" = ["${REGISTRY}/console:latest"]
}[tgt]
target = tgt
}
target "console-build" {
target = "console-build"
target "_core" {
dockerfile = "Dockerfile.core"
context = "."
contexts = {
node = "docker-image://golang:1.23"
console = "target:console-output"
}
args = {
SASS_VERSION = "1.64.1"
GOLANG_CI_VERSION = "1.64.5"
}
}
target "console-lint" {
target = "console-lint"
}
target "console-image" {
target = "console-image"
tags = [
"${REGISTRY}/console:${GITHUB_SHA}",
]
}
target "console-output" {
target = "console-output"
output = ["type=local,dest=.build/console"]
}
target "core-base" {
target = "core-base"
}
target "core-build" {
target = "core-build"
}
target "core-lint" {
target = "core-lint"
}
target "core-image" {
target = "core-image"
tags = [
"${REGISTRY}/zitadel:${GITHUB_SHA}",
]
}
target "core-output" {
target = "core-output"
output = ["type=local,dest=.build/core"]
}
target "core-unit-test" {
target = "core-unit-test"
target "core" {
name = "core-${tgt}"
inherits = ["_core"]
matrix = {
tgt = ["build", "output", "lint", "image"]
}
output = {
"build" = ["type=cacheonly"]
"output" = ["type=local,dest=.build/core"]
"lint" = ["type=cacheonly"]
"image" = ["type=docker"]
}[tgt]
tags = {
"build" = []
"output" = []
"lint" = []
"image" = ["${REGISTRY}/zitadel:latest"]
}[tgt]
target = tgt
}

27
nginx.conf Normal file
View File

@ -0,0 +1,27 @@
# the events block is required
events{}
http {
# include the default mime.types to map file extensions to MIME types
include /etc/nginx/mime.types;
server {
# set the root directory for the server (we need to copy our
# application files here)
root /usr/share/nginx/html;
# set the default index file for the server (Angular generates the
# index.html file for us and it will be in the above directory)
index index.html;
# specify the configuration for the '/' location
location / {
# try to serve the requested URI. if that fails then try to
# serve the URI with a trailing slash. if that fails, then
# serve the index.html file; this is needed in order to serve
# Angular routes--e.g.,'localhost:8080/customer' will serve
# the index.html file
try_files $uri $uri/ /index.html;
}
}
}