From ee0c58ad2859a57f67272439b9b29f0e111c4866 Mon Sep 17 00:00:00 2001 From: Timothy Kim Date: Wed, 8 Apr 2026 20:23:22 -0400 Subject: [PATCH] adds goatcounter --- .gitea/workflows/deploy-goatcounter.yml | 19 +++++++++++ docker/goatcounter/.gitignore | 2 ++ docker/goatcounter/compose.yaml | 18 +++++++++++ .../nginx/conf.d/goatcounter.hantim.net.conf | 32 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 .gitea/workflows/deploy-goatcounter.yml create mode 100644 docker/goatcounter/.gitignore create mode 100644 docker/goatcounter/compose.yaml create mode 100644 docker/nginx/conf.d/goatcounter.hantim.net.conf diff --git a/.gitea/workflows/deploy-goatcounter.yml b/.gitea/workflows/deploy-goatcounter.yml new file mode 100644 index 0000000..094a458 --- /dev/null +++ b/.gitea/workflows/deploy-goatcounter.yml @@ -0,0 +1,19 @@ +name: Deploy goatcounter + +on: + push: + branches: [main] + paths: + - 'docker/goatcounter/**' + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Deploy via SSH + run: | + mkdir -p ~/.ssh + echo "${{ vars.DEPLOY_HOST_KEY }}" > ~/.ssh/known_hosts + echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + ssh -o StrictHostKeyChecking=yes -i ~/.ssh/deploy_key deploy@${{ vars.DEPLOY_HOST }} deploy-goatcounter diff --git a/docker/goatcounter/.gitignore b/docker/goatcounter/.gitignore new file mode 100644 index 0000000..7cf9f0b --- /dev/null +++ b/docker/goatcounter/.gitignore @@ -0,0 +1,2 @@ +# !create +db/ diff --git a/docker/goatcounter/compose.yaml b/docker/goatcounter/compose.yaml new file mode 100644 index 0000000..9a5ec9e --- /dev/null +++ b/docker/goatcounter/compose.yaml @@ -0,0 +1,18 @@ +services: + goatcounter: + image: baethon/goatcounter + restart: unless-stopped + container_name: goatcounter + command: >- + goatcounter serve + -listen :8080 + -tls none + -db sqlite3+/goatcounter/db/goatcounter.sqlite3 + volumes: + - ./db:/goatcounter/db + networks: + - shared + +networks: + shared: + external: true diff --git a/docker/nginx/conf.d/goatcounter.hantim.net.conf b/docker/nginx/conf.d/goatcounter.hantim.net.conf new file mode 100644 index 0000000..06b3bda --- /dev/null +++ b/docker/nginx/conf.d/goatcounter.hantim.net.conf @@ -0,0 +1,32 @@ +server { + listen 80; + listen [::]:80; + server_name goatcounter.hantim.net; + + location /.well-known/acme-challenge/ { + root /var/www/certbot; + } + + location / { + return 301 https://goatcounter.hantim.net$request_uri; + } +} + +server { + listen 443 ssl; + listen [::]:443 ssl; + http2 on; + server_name goatcounter.hantim.net; + + ssl_certificate /etc/letsencrypt/live/goatcounter.hantim.net/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/goatcounter.hantim.net/privkey.pem; + + include /etc/nginx/conf.d/security-headers.inc; + + location / { + proxy_pass http://goatcounter:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +}