Update static-site hosting
This commit is contained in:
parent
98d8a8190b
commit
82a08bf071
2 changed files with 64 additions and 21 deletions
21
README.md
21
README.md
|
|
@ -92,7 +92,7 @@ traefik-rule: Host(`example.com`) && PathPrefix(`/docs`)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /srv/infra
|
cd /srv/infra
|
||||||
bosun dispatch s3
|
nix run .#bosun -- run s3
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Create artifacts bucket
|
### 2. Create artifacts bucket
|
||||||
|
|
@ -111,19 +111,14 @@ aws s3 mb s3://artifacts
|
||||||
aws s3api put-bucket-acl --bucket artifacts --acl public-read
|
aws s3api put-bucket-acl --bucket artifacts --acl public-read
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Deploy static-site parameterized job
|
### 3. Add Forgejo secrets
|
||||||
|
|
||||||
```bash
|
|
||||||
cd /srv/infra
|
|
||||||
bosun dispatch static-site-dispatch
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. Add Forgejo secrets
|
|
||||||
|
|
||||||
In your repository settings (or organization settings for global secrets):
|
In your repository settings (or organization settings for global secrets):
|
||||||
- `S3_ACCESS_KEY`: The access key from S3 credentials
|
- `S3_ACCESS_KEY`: The access key from S3 credentials
|
||||||
- `S3_SECRET_KEY`: The secret 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
|
## Examples
|
||||||
|
|
||||||
### Simple HTML site
|
### Simple HTML site
|
||||||
|
|
@ -237,14 +232,6 @@ Check that:
|
||||||
2. The credentials match those in the S3 Nomad job config
|
2. The credentials match those in the S3 Nomad job config
|
||||||
3. S3 service is running: `nomad job status s3`
|
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
|
### Site not accessible
|
||||||
Check:
|
Check:
|
||||||
1. Nomad allocation is running: `nomad job status static-site`
|
1. Nomad allocation is running: `nomad job status static-site`
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,66 @@ runs:
|
||||||
- name: Deploy via Nomad
|
- name: Deploy via Nomad
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
nomad job dispatch static-site \
|
cat > /tmp/deploy-${{ inputs.site-name }}.nomad.json <<'NOMAD_EOF'
|
||||||
-meta site_name=${{ inputs.site-name }} \
|
{
|
||||||
-meta traefik_rule="${{ inputs.traefik-rule }}" \
|
"Job": {
|
||||||
-meta artifact_url=${{ inputs.s3-endpoint }}/artifacts/${{ github.sha }}.tar.gz
|
"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
|
- name: Deployment summary
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue