Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
- hetzner-deploy-frontend
- podman-deploy-backend
# pull_request:
# types: [ opened, synchronize, reopened ]

Expand Down Expand Up @@ -55,6 +55,27 @@ jobs:
api_location: "" # Api source code path - optional
###### End of Repository/Build Configurations ######

build-backend-container:
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/zenmo/coco-backend:${{ env.TAG }}
context: ./webtool/gradle
file: ./webtool/deploy/backend/Dockerfile

build-frontend-container:
runs-on: ubuntu-24.04
steps:
Expand All @@ -72,7 +93,9 @@ jobs:

deploy-podhost:
runs-on: ubuntu-24.04
needs: build-frontend-container
needs:
- build-frontend-container
- build-backend-container
steps:
- uses: actions/checkout@v5
- name: Install SSH key
Expand All @@ -83,29 +106,15 @@ jobs:
- name: Deploy podhost
run: ./webtool/deploy/quadlets/deploy.sh

deploy-backend:
deploy-swarm:
runs-on: ubuntu-latest
needs: build-backend-container
steps:
- name: Check out repository
uses: actions/checkout@main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/zenmo/local4local-backend:${{ github.run_number }}
context: ./webtool/gradle
- uses: actions/checkout@v5
- name: Deploy to swarm
uses: sagebind/docker-swarm-deploy-action@v2
env:
GITHUB_RUN_NUMBER: ${{ github.run_number }}
TAG: ${{ env.TAG }}
with:
remote_host: ssh://root@server.zenmo.com
ssh_private_key: ${{ secrets.SWARM_SSH_PRIVATE_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion webtool/compose-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
backend:
image: ghcr.io/zenmo/local4local-backend:${GITHUB_RUN_NUMBER}
image: ghcr.io/zenmo/coco-backend:${TAG}
networks:
- caddy_default
labels:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dockerfile for production environment

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

COPY . /home/gradle
RUN gradle backend:shadowJar
Expand All @@ -9,4 +9,6 @@ FROM amazoncorretto:21-al2023-headless

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

CMD java -jar /app/backend.jar
EXPOSE 9000

CMD ["java", "-jar", "/app/backend.jar"]
17 changes: 17 additions & 0 deletions webtool/deploy/quadlets/coco-backend.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

[Container]
ContainerName=coco-backend
Image=ghcr.io/zenmo/coco-backend:$TAG

Network=main.network
Label=traefik.enable=true
Label=traefik.http.routers.coco-backend.rule=Host(`local4local-backend.zenmo.com`)
Label=traefik.http.routers.coco-backend.tls.certResolver=DNSimpleChallenge
Label=traefik.http.routers.coco-backend.tls.domains[0].main=*.zenmo.com

[Service]
Restart=always
TimeoutStartSec=300

[Install]
WantedBy=default.target
3 changes: 2 additions & 1 deletion webtool/deploy/quadlets/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ scp -r $OUTPUT_DIR podman@podhost.zenmo.com:~/.config/containers/systemd/
# Restart services
ssh podman@podhost.zenmo.com "\
systemctl --user daemon-reload \
&& systemctl --user restart coco-frontend"
&& systemctl --user restart coco-frontend \
&& systemctl --user restart coco-backend"
Loading