Skip to content

Commit 3ebd2aa

Browse files
committed
Deploy backend as quadlet
1 parent e20cd64 commit 3ebd2aa

File tree

5 files changed

+51
-24
lines changed

5 files changed

+51
-24
lines changed

.github/workflows/deploy.yaml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
- hetzner-deploy-frontend
7+
- podman-deploy-backend
88
# pull_request:
99
# types: [ opened, synchronize, reopened ]
1010

@@ -55,6 +55,27 @@ jobs:
5555
api_location: "" # Api source code path - optional
5656
###### End of Repository/Build Configurations ######
5757

58+
build-backend-container:
59+
runs-on: ubuntu-24.04
60+
steps:
61+
- name: Check out repository
62+
uses: actions/checkout@main
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
- name: Log in GitHub Container Registry
66+
uses: docker/login-action@v2
67+
with:
68+
registry: ghcr.io
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
- name: Build and push
72+
uses: docker/build-push-action@v6
73+
with:
74+
push: true
75+
tags: ghcr.io/zenmo/coco-backend:${{ env.TAG }}
76+
context: ./webtool/gradle
77+
file: ./webtool/deploy/backend/Dockerfile
78+
5879
build-frontend-container:
5980
runs-on: ubuntu-24.04
6081
steps:
@@ -72,7 +93,9 @@ jobs:
7293

7394
deploy-podhost:
7495
runs-on: ubuntu-24.04
75-
needs: build-frontend-container
96+
needs:
97+
- build-frontend-container
98+
- build-backend-container
7699
steps:
77100
- uses: actions/checkout@v5
78101
- name: Install SSH key
@@ -83,29 +106,15 @@ jobs:
83106
- name: Deploy podhost
84107
run: ./webtool/deploy/quadlets/deploy.sh
85108

86-
deploy-backend:
109+
deploy-swarm:
87110
runs-on: ubuntu-latest
111+
needs: build-backend-container
88112
steps:
89-
- name: Check out repository
90-
uses: actions/checkout@main
91-
- name: Set up Docker Buildx
92-
uses: docker/setup-buildx-action@v3
93-
- name: Log in GitHub Container Registry
94-
uses: docker/login-action@v2
95-
with:
96-
registry: ghcr.io
97-
username: ${{ github.actor }}
98-
password: ${{ secrets.GITHUB_TOKEN }}
99-
- name: Build and push
100-
uses: docker/build-push-action@v6
101-
with:
102-
push: true
103-
tags: ghcr.io/zenmo/local4local-backend:${{ github.run_number }}
104-
context: ./webtool/gradle
113+
- uses: actions/checkout@v5
105114
- name: Deploy to swarm
106115
uses: sagebind/docker-swarm-deploy-action@v2
107116
env:
108-
GITHUB_RUN_NUMBER: ${{ github.run_number }}
117+
TAG: ${{ env.TAG }}
109118
with:
110119
remote_host: ssh://root@server.zenmo.com
111120
ssh_private_key: ${{ secrets.SWARM_SSH_PRIVATE_KEY }}

webtool/compose-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.8"
22

33
services:
44
backend:
5-
image: ghcr.io/zenmo/local4local-backend:${GITHUB_RUN_NUMBER}
5+
image: ghcr.io/zenmo/coco-backend:${TAG}
66
networks:
77
- caddy_default
88
labels:
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dockerfile for production environment
22

3-
FROM gradle:8.13-jdk21 AS builder
3+
FROM docker.io/library/gradle:8.13-jdk21 AS builder
44

55
COPY . /home/gradle
66
RUN gradle backend:shadowJar
@@ -9,4 +9,4 @@ FROM amazoncorretto:21-al2023-headless
99

1010
COPY --from=builder /home/gradle/backend/build/libs/backend.jar /app/backend.jar
1111

12-
CMD java -jar /app/backend.jar
12+
CMD ["java", "-jar", "/app/backend.jar"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
[Container]
3+
ContainerName=coco-backend
4+
Image=ghcr.io/zenmo/coco-backend:$TAG
5+
6+
Network=main.network
7+
Label=traefik.enable=true
8+
Label=traefik.http.routers.coco-backend.rule=Host(`local4local-backend.zenmo.com`)
9+
Label=traefik.http.routers.coco-backend.tls.certResolver=DNSimpleChallenge
10+
Label=traefik.http.routers.coco-backend.tls.domains[0].main=*.zenmo.com
11+
12+
[Service]
13+
Restart=always
14+
TimeoutStartSec=300
15+
16+
[Install]
17+
WantedBy=default.target

webtool/deploy/quadlets/deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ scp -r $OUTPUT_DIR podman@podhost.zenmo.com:~/.config/containers/systemd/
1919
# Restart services
2020
ssh podman@podhost.zenmo.com "\
2121
systemctl --user daemon-reload \
22-
&& systemctl --user restart coco-frontend"
22+
&& systemctl --user restart coco-frontend \
23+
&& systemctl --user restart coco-backend"

0 commit comments

Comments
 (0)