From 82a08bf0715eee16e04c99d6ee19a54a72099eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20M=C3=BChl?= Date: Mon, 16 Feb 2026 14:28:12 +0100 Subject: [PATCH] Update static-site hosting --- README.md | 21 +++----------- deploy-site/action.yaml | 64 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 9cd32be..f992adc 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ traefik-rule: Host(`example.com`) && PathPrefix(`/docs`) ```bash cd /srv/infra -bosun dispatch s3 +nix run .#bosun -- run s3 ``` ### 2. Create artifacts bucket @@ -111,19 +111,14 @@ aws s3 mb s3://artifacts aws s3api put-bucket-acl --bucket artifacts --acl public-read ``` -### 3. Deploy static-site parameterized job - -```bash -cd /srv/infra -bosun dispatch static-site-dispatch -``` - -### 4. Add Forgejo secrets +### 3. Add Forgejo secrets In your repository settings (or organization settings for global secrets): - `S3_ACCESS_KEY`: The access key from S3 credentials - `S3_SECRET_KEY`: The secret key from S3 credentials +That's it! The action will automatically create individual Nomad service jobs for each site. + ## Examples ### Simple HTML site @@ -237,14 +232,6 @@ Check that: 2. The credentials match those in the S3 Nomad job config 3. S3 service is running: `nomad job status s3` -### Nomad dispatch fails -Ensure the `static-site` parameterized job is running: -```bash -nomad job status static-site -# If not found: -bosun dispatch static-site-dispatch -``` - ### Site not accessible Check: 1. Nomad allocation is running: `nomad job status static-site` diff --git a/deploy-site/action.yaml b/deploy-site/action.yaml index ef02f9d..d332fec 100644 --- a/deploy-site/action.yaml +++ b/deploy-site/action.yaml @@ -59,10 +59,66 @@ runs: - name: Deploy via Nomad shell: bash run: | - nomad job dispatch static-site \ - -meta site_name=${{ inputs.site-name }} \ - -meta traefik_rule="${{ inputs.traefik-rule }}" \ - -meta artifact_url=${{ inputs.s3-endpoint }}/artifacts/${{ github.sha }}.tar.gz + cat > /tmp/deploy-${{ inputs.site-name }}.nomad.json <<'NOMAD_EOF' + { + "Job": { + "ID": "${{ inputs.site-name }}", + "Name": "${{ inputs.site-name }}", + "Type": "service", + "Datacenters": ["contabo"], + "Constraints": [{ + "LTarget": "${node.unique.name}", + "RTarget": "alvin", + "Operand": "=" + }], + "TaskGroups": [{ + "Name": "web", + "Count": 1, + "Networks": [{ + "Mode": "bridge", + "DynamicPorts": [{ + "Label": "http", + "To": 8080 + }] + }], + "Services": [{ + "Name": "${{ inputs.site-name }}", + "PortLabel": "http", + "Provider": "nomad", + "Tags": [ + "traefik.enable=true", + "traefik.http.routers.${{ inputs.site-name }}.rule=${{ inputs.traefik-rule }}", + "traefik.http.routers.${{ inputs.site-name }}.entrypoints=websecure", + "traefik.http.routers.${{ inputs.site-name }}.tls.certresolver=letsencrypt" + ] + }], + "Tasks": [{ + "Name": "server", + "Driver": "docker", + "Config": { + "image": "joseluisq/static-web-server:2", + "ports": ["http"] + }, + "Env": { + "SERVER_ROOT": "/local/public", + "SERVER_LOG_LEVEL": "info" + }, + "Artifacts": [{ + "GetterSource": "${{ inputs.s3-endpoint }}/artifacts/${{ github.sha }}.tar.gz", + "RelativeDest": "local/public", + "GetterMode": "dir" + }], + "Resources": { + "CPU": 100, + "MemoryMB": 64 + } + }] + }] + } + } + NOMAD_EOF + + nomad job run /tmp/deploy-${{ inputs.site-name }}.nomad.json - name: Deployment summary shell: bash