Skip to content

Commit 6ce72bd

Browse files
authored
Merge pull request #25 from swaroopar/feature/buildDevZitadelImage
Feature/build dev zitadel image
2 parents c4d2a80 + 64286b8 commit 6ce72bd

23 files changed

+535
-136
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build Zitadel Dev Images
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
BOT_USER_NAME: eclipse-xpanse-bot
8+
BOT_EMAIL_ID: [email protected]
9+
REGISTRY: ghcr.io
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
18+
steps:
19+
- name: Check out code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v2
24+
25+
- name: Login to Github Packages
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ env.BOT_USER_NAME }}
30+
password: ${{ secrets.BOT_GITHUB_DOCKER_TOKEN }}
31+
32+
- name: Set up Terraform
33+
uses: hashicorp/setup-terraform@v3
34+
with:
35+
terraform_version: 1.6.1
36+
37+
- name: build custom postgres image with changed PGDATA
38+
run: |
39+
docker build -t custom-pg-db:latest .
40+
working-directory: zitadel/local/build
41+
42+
- name: start containers using docker build
43+
run: |
44+
mkdir ${{ runner.temp }}/machinekey
45+
VOLUME_POINT=${{ runner.temp }}/machinekey docker compose up -d
46+
working-directory: zitadel/local/build
47+
48+
- name: Wait for API Response
49+
uses: mydea/action-wait-for-api@v1
50+
continue-on-error: true
51+
with:
52+
url: "http://localhost:8088/debug/healthz"
53+
expected-status: "200" # You can specify other 2xx codes as needed
54+
timeout: "60" # Maximum wait time in seconds
55+
interval: "10"
56+
57+
- name: copy admin service account key
58+
run: |
59+
cp ${{ runner.temp }}/machinekey/* .
60+
working-directory: zitadel/terraform
61+
62+
- name: configure Zitadel
63+
run: |
64+
terraform init
65+
terraform apply -var-file=environments/local.tfvars -auto-approve
66+
terraform output -json > output.json
67+
working-directory: zitadel/terraform
68+
69+
- name: Upload Artifacts
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: access details # Name of the artifact
73+
path: zitadel/terraform/*.json
74+
75+
- name: commit images
76+
run: |
77+
JOB_LINK="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
78+
docker stop compose-zitadel-1
79+
docker stop compose-db-1
80+
docker commit --change="LABEL job_link=\"$JOB_LINK\"" compose-zitadel-1 xpanse-zitadel-dev-server
81+
docker commit --change="LABEL job_link=\"$JOB_LINK\"" compose-db-1 xpanse-zitadel-dev-db
82+
83+
- name: Build and push Docker image
84+
run: |
85+
JOB_LINK="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
86+
docker tag xpanse-zitadel-dev-server:latest ${{ env.REGISTRY }}/${{ github.repository_owner }}/xpanse-zitadel-dev-server:latest
87+
docker tag xpanse-zitadel-dev-db:latest ${{ env.REGISTRY }}/${{ github.repository_owner }}/xpanse-zitadel-dev-db:latest
88+
docker push ${{ env.REGISTRY }}/${{ github.repository_owner }}/xpanse-zitadel-dev-server:latest
89+
docker push ${{ env.REGISTRY }}/${{ github.repository_owner }}/xpanse-zitadel-dev-db:latest

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
*.hcl
66
*.tfstate
77
*token.json
8-
*.tfstate.backup
8+
*.tfstate.backup
9+
zitadel-admin-sa.json

zitadel/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config the xpanse project with the service instance of Zitadel.
1212

1313
Here are two types of service instance deployment solutions. You can deploy a local service instance
1414
of Zitadel according
15-
to the document [local-installation-steps.md](local/local-installation-steps.md) or deploy a
15+
to the document [local-installation-steps.md](local/run/run-dev-zitadel-containers) or deploy a
1616
production service instance of
1717
Zitadel according to the
1818
document [testbed-installation-steps.md](testlab/testbed-installation-steps.md).

zitadel/local/build/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM postgres:16-alpine
2+
3+
# This is necessary. Otherwise the data written to the container will not be part of the created image.
4+
RUN mkdir -p /var/lib/postgresql-static/data
5+
ENV PGDATA=/var/lib/postgresql-static/data
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Build Zitadel Dev Docker Images
2+
3+
To enhance developer experience, we prepare the Zitadel development docker images with all necessary configurations.
4+
The developer will have to simply start these application and database docker containers and
5+
then the environment is ready to use without any additional configuration.
6+
7+
## Image Build Job
8+
9+
The GitHub action [build-dev-images](../../../.github/workflows/build-zitadel-dev-images.yml) builds the necessary images
10+
and uploads it to the GitHub packages and also uploads all configuration details to action artifacts.
11+
12+
> Images will be always simply built with 'latest' tag.
13+
14+
## Configure Client Systems
15+
16+
Whenever this job is executed, the images generated will contain new information for all clients.
17+
Hence, it is necessary for the developer to also update the following files whenever a new image is created
18+
and also inform team that the latest images must be pulled.
19+
20+
- [xpanse UI auth config](https://github.com/eclipse-xpanse/xpanse-ui/blob/main/.env.zitadel-local)
21+
- [xpanse app auth config](https://github.com/eclipse-xpanse/xpanse/blob/main/runtime/src/main/resources/application-zitadel.properties)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
services:
2+
zitadel:
3+
user: "${UID:-1001}"
4+
restart: 'always'
5+
networks:
6+
- 'zitadel'
7+
image: 'ghcr.io/zitadel/zitadel:latest'
8+
command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled'
9+
environment:
10+
ZITADEL_DATABASE_POSTGRES_HOST: db
11+
ZITADEL_DATABASE_POSTGRES_PORT: 5432
12+
ZITADEL_DATABASE_POSTGRES_DATABASE: zitadel
13+
ZITADEL_DATABASE_POSTGRES_USER_USERNAME: zitadel
14+
ZITADEL_DATABASE_POSTGRES_USER_PASSWORD: zitadel
15+
ZITADEL_DATABASE_POSTGRES_USER_SSL_MODE: disable
16+
ZITADEL_DATABASE_POSTGRES_ADMIN_USERNAME: postgres
17+
ZITADEL_DATABASE_POSTGRES_ADMIN_PASSWORD: postgres
18+
ZITADEL_DATABASE_POSTGRES_ADMIN_SSL_MODE: disable
19+
ZITADEL_EXTERNALSECURE: false
20+
ZITADEL_FIRSTINSTANCE_MACHINEKEYPATH: /machinekey/zitadel-admin-sa.json
21+
ZITADEL_FIRSTINSTANCE_ORG_MACHINE_MACHINE_USERNAME: zitadel-admin-sa
22+
ZITADEL_FIRSTINSTANCE_ORG_MACHINE_MACHINE_NAME: Admin
23+
ZITADEL_FIRSTINSTANCE_ORG_MACHINE_MACHINEKEY_TYPE: 1
24+
ZITADEL_FIRSTINSTANCE_ORG_HUMAN_PASSWORDCHANGEREQUIRED: false
25+
ZITADEL_FIRSTINSTANCE_ORG_HUMAN_PASSWORD: Zitadel@123 # Default admin password.
26+
depends_on:
27+
db:
28+
condition: 'service_healthy'
29+
ports:
30+
- '8088:8080'
31+
volumes:
32+
- ${VOLUME_POINT:-./machinekey}:/machinekey:rw
33+
34+
db:
35+
restart: 'always'
36+
image: custom-pg-db # Custom postgres image.
37+
environment:
38+
PGUSER: postgres
39+
POSTGRES_PASSWORD: postgres
40+
networks:
41+
- 'zitadel'
42+
healthcheck:
43+
test: [ "CMD-SHELL", "pg_isready", "-d", "zitadel", "-U", "postgres" ]
44+
interval: '10s'
45+
timeout: '2400s'
46+
retries: 500
47+
start_period: '20s'
48+
49+
networks:
50+
zitadel:

zitadel/local/build/machinekey/.gitkeep

Whitespace-only changes.

zitadel/local/compose/docker-compose-local.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

zitadel/local/local-installation-steps.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

zitadel/local/run/docker-compose.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
services:
2+
zitadel:
3+
# The user should have the permission to write to ./machinekey
4+
user: "${UID:-1001}"
5+
restart: 'always'
6+
networks:
7+
- 'zitadel-dev'
8+
image: ghcr.io/eclipse-xpanse/xpanse-zitadel-dev-server:latest # image built locally by commiting an already initialized zitadel server
9+
command: 'start --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled'
10+
depends_on:
11+
db:
12+
condition: 'service_healthy'
13+
ports:
14+
- '8088:8080'
15+
16+
db:
17+
restart: 'always'
18+
image: ghcr.io/eclipse-xpanse/xpanse-zitadel-dev-db:latest # image built locally by commiting an already initialized zitadel Postgres DB
19+
healthcheck:
20+
test: [ "CMD-SHELL", "pg_isready", "-d", "zitadel", "-U", "postgres" ]
21+
interval: '10s'
22+
timeout: '2400s'
23+
retries: 500
24+
start_period: '20s'
25+
networks:
26+
- 'zitadel-dev'
27+
28+
networks:
29+
zitadel-dev:

0 commit comments

Comments
 (0)