Skip to content

Commit fca2c82

Browse files
committed
Deploy frontend to podhost
1 parent fa3460d commit fca2c82

File tree

7 files changed

+96
-2
lines changed

7 files changed

+96
-2
lines changed

.github/workflows/deploy.yaml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ on:
44
push:
55
branches:
66
- main
7+
- hetzner-deploy-frontend
78
# pull_request:
89
# types: [ opened, synchronize, reopened ]
910

11+
env:
12+
TAG: ${{ github.head_ref || github.ref_name }}-${{ github.run_number }}
13+
1014
jobs:
11-
build-deploy-static-site:
15+
build-deploy-azure-static-site:
1216
runs-on: ubuntu-latest
1317
name: Build and deploy static site
1418
steps:
@@ -51,6 +55,34 @@ jobs:
5155
api_location: "" # Api source code path - optional
5256
###### End of Repository/Build Configurations ######
5357

58+
build-frontend-container:
59+
runs-on: ubuntu-24.04
60+
steps:
61+
- uses: actions/checkout@v5
62+
- name: Log in to GitHub Container Registry
63+
uses: redhat-actions/podman-login@v1
64+
with:
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
registry: ghcr.io
68+
- name: Build container image
69+
run: ./webtool/deploy/frontend/build.sh
70+
- name: Push container image
71+
run: ./webtool/deploy/frontend/push.sh
72+
73+
deploy-podhost:
74+
runs-on: ubuntu-24.04
75+
needs: build-frontend-container
76+
steps:
77+
- uses: actions/checkout@v5
78+
- name: Install SSH key
79+
uses: shimataro/ssh-key-action@v2
80+
with:
81+
key: ${{ secrets.PODHOST_SSH_PRIVATE_KEY }}
82+
known_hosts: podhost.zenmo.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKVeen0rfyMwiAoQCpIUJ/a2tpM35D/BdEDUyfRTxiXm
83+
- name: Deploy podhost
84+
run: ./webtool/deploy/quadlets/deploy.sh
85+
5486
deploy-backend:
5587
runs-on: ubuntu-latest
5688
steps:
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ ARG VITE_ANYLOGIC_CALLBACK_URL=https://local4local-backend.zenmo.com
2424

2525
# Build static site
2626
COPY frontend /app/frontend
27-
RUN ls -ahl
2827
RUN npm run build
2928

3029
# Final image

webtool/deploy/frontend/build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
cd $(dirname "$0")
6+
7+
TAG="${TAG:-dev}"
8+
9+
podman build \
10+
--file Dockerfile \
11+
--ignorefile .dockerignore \
12+
--tag ghcr.io/zenmo/coco-frontend:$TAG \
13+
--progress=plain \
14+
$@ \
15+
../..

webtool/deploy/frontend/push.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
TAG="${TAG:-dev}"
2+
3+
podman push \
4+
ghcr.io/zenmo/coco-frontend:$TAG \
5+
docker://ghcr.io/zenmo/coco-frontend:$TAG
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
[Container]
3+
ContainerName=coco-frontend
4+
Image=ghcr.io/zenmo/coco-frontend:$TAG
5+
6+
Network=main.network
7+
Label=traefik.enable=true
8+
Label="traefik.http.routers.coco-frontend.rule=Host(`coco.local4local.nu`) || Host(`cooperatieconfigurator.local4local.nu`)"
9+
Label=traefik.http.routers.coco-frontend.tls.certResolver=HttpChallenge
10+
Label=traefik.http.routers.coco-frontend.tls.domains[0].main=coco.local4local.nu
11+
Label=traefik.http.routers.coco-frontend.tls.domains[1].main=cooperatieconfigurator.local4local.nu
12+
Label=traefik.http.routers.coco-frontend.middlewares[0]=coco-redirect
13+
Label=traefik.http.middlewares.coco-redirect.redirectRegex.regex=^https://cooperatieconfigurator.local4local.nu/(.*)
14+
Label=traefik.http.middlewares.coco-redirect.redirectRegex.replacement=https://coco.local4local.nu/${1}
15+
16+
[Service]
17+
Restart=always
18+
TimeoutStartSec=300
19+
20+
[Install]
21+
WantedBy=default.target

webtool/deploy/quadlets/deploy.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Set up Quadlet config files, copy them to the Podman host, and restart the services.
3+
# This is a simplified version of the script at https://github.com/Zenmo/lux-website/blob/main/deploy/quadlets/deploy.sh
4+
5+
set -ex
6+
cd $(dirname "$0")
7+
8+
OUTPUT_DIR=coco
9+
mkdir -p $OUTPUT_DIR
10+
11+
# Prepare Quadlet files
12+
for filename in *.container; do
13+
envsubst < "$filename" > "$OUTPUT_DIR/$filename"
14+
done
15+
16+
# Copy files to the Podman host
17+
scp -r $OUTPUT_DIR podman@podhost.zenmo.com:~/.config/containers/systemd/
18+
19+
# Restart services
20+
ssh podman@podhost.zenmo.com "\
21+
systemctl --user daemon-reload \
22+
&& systemctl --user restart coco-frontend"

0 commit comments

Comments
 (0)