chore(ci): test docker bake

This commit is contained in:
Florian Forster
2025-02-18 17:40:41 +01:00
parent 5bbb953ffb
commit 8101516442
2 changed files with 90 additions and 0 deletions

42
Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
ARG NODE_VERSION=22
ARG GO_VERSION=1.23
## Console Base
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
## Console Build
FROM console-base AS console-build
COPY console/ .
COPY docs/frameworks.json ../docs/frameworks.json
RUN yarn build
## Console Image
FROM nginx:stable-alpine AS console
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;"]
## Core Base
FROM golang:${GO_VERSION} AS core-base
ARG SASS_VERSION=1.64.1
RUN apt-get update && apt-get install -y npm && npm install -g sass@${SASS_VERSION}
WORKDIR /app
COPY go.mod go.sum Makefile buf.gen.yaml buf.work.yaml main.go ./
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 ls -la proto/zitadel
RUN make core_build
## Core Unit Test
FROM core-base AS core-unit-test
RUN make core_unit_test

48
docker-bake.hcl Normal file
View File

@@ -0,0 +1,48 @@
variable "GITHUB_SHA" {
default = "latest"
}
variable "REGISTRY" {
default = "ghcr.io/zitadel"
}
group "generate" {
targets = ["console-base"]
}
group "unit-test" {
targets = ["core-unit-test"]
}
target "console-base" {
target = "console-base"
cache-from = ["type=gha,scope=console-base"]
cache-to = ["type=gha,mode=max,scope=console-base"]
}
target "console-builder" {
target = "console-builder"
cache-from = ["type=gha,scope=console-builder"]
cache-to = ["type=gha,mode=max,scope=console-builder"]
}
target "console" {
target = "console"
tags = [
"${REGISTRY}/console:${GITHUB_SHA}",
]
cache-from = ["type=gha,scope=console"]
cache-to = ["type=gha,mode=max,scope=console"]
}
target "core-base" {
target = "core-base"
cache-from = ["type=gha,scope=core-base"]
cache-to = ["type=gha,mode=max,scope=core-base"]
}
target "core-unit-test" {
target = "core-unit-test"
cache-from = ["type=gha,scope=core-unit-test"]
cache-to = ["type=gha,mode=max,scope=core-unit-test"]
}