Add registry.lunarfront.tech: DNS-only subdomain with Let's Encrypt cert, no CF upload limit

This commit is contained in:
Ryan Moon
2026-03-31 19:14:03 -05:00
parent c280fb8cbe
commit 1ce49a7ed3
7 changed files with 96 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ on:
jobs:
ansible:
runs-on: ubuntu-latest
container: git.lunarfront.tech/ryan/ci-runner:latest
container: registry.lunarfront.tech/ryan/ci-runner:latest
defaults:
run:
working-directory: ansible

View File

@@ -25,13 +25,13 @@ jobs:
apt-get install -y docker-ce-cli
- name: Login to Gitea registry
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.lunarfront.tech -u ryan --password-stdin
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login registry.lunarfront.tech -u ryan --password-stdin
- name: Build and push
run: |
docker build -t git.lunarfront.tech/ryan/ci-runner:latest runner/
docker push git.lunarfront.tech/ryan/ci-runner:latest
docker build -t registry.lunarfront.tech/ryan/ci-runner:latest runner/
docker push registry.lunarfront.tech/ryan/ci-runner:latest
- name: Logout
if: always()
run: docker logout git.lunarfront.tech
run: docker logout registry.lunarfront.tech

View File

@@ -20,7 +20,7 @@ on:
jobs:
terraform:
runs-on: ubuntu-latest
container: git.lunarfront.tech/ryan/ci-runner:latest
container: registry.lunarfront.tech/ryan/ci-runner:latest
defaults:
run:
working-directory: terraform

View File

@@ -5,6 +5,9 @@ gitea_http_port: 3000
gitea_ssh_port: 2222
gitea_data_dir: /var/lib/gitea
gitea_registry_domain: "registry.example.com"
letsencrypt_email: ""
# Cloudflare Origin Certificate
cf_origin_cert: ""
cf_origin_key: ""

View File

@@ -86,3 +86,51 @@
name: nginx
enabled: true
state: started
# ─── Registry (Let's Encrypt cert, DNS-only / no Cloudflare proxy) ────────────
- name: Install certbot and Cloudflare DNS plugin
apt:
name: [certbot, python3-certbot-dns-cloudflare]
state: present
- name: Write Cloudflare credentials for certbot
copy:
content: |
dns_cloudflare_api_token = {{ cloudflare_api_token }}
dest: /etc/letsencrypt/cloudflare.ini
owner: root
group: root
mode: "0600"
- name: Obtain Let's Encrypt cert for registry domain
command: >
certbot certonly
--dns-cloudflare
--dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini
--non-interactive
--agree-tos
--email {{ letsencrypt_email }}
-d {{ gitea_registry_domain }}
args:
creates: /etc/letsencrypt/live/{{ gitea_registry_domain }}/fullchain.pem
- name: Deploy registry nginx config
template:
src: nginx-registry.conf.j2
dest: /etc/nginx/sites-available/registry
mode: "0644"
notify: Reload nginx
- name: Enable registry nginx site
file:
src: /etc/nginx/sites-available/registry
dest: /etc/nginx/sites-enabled/registry
state: link
notify: Reload nginx
- name: Enable certbot renewal timer
systemd:
name: certbot.timer
enabled: true
state: started

View File

@@ -0,0 +1,26 @@
server {
listen 80;
server_name {{ gitea_registry_domain }};
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name {{ gitea_registry_domain }};
ssl_certificate /etc/letsencrypt/live/{{ gitea_registry_domain }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ gitea_registry_domain }}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
client_max_body_size 0;
location / {
proxy_pass http://127.0.0.1:{{ gitea_http_port }};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View File

@@ -98,17 +98,18 @@ resource "digitalocean_firewall" "gitea" {
source_addresses = ["${var.admin_ip}/32"]
}
# HTTP/HTTPS — Cloudflare IPs only
# HTTP — Cloudflare IPs only (web UI)
inbound_rule {
protocol = "tcp"
port_range = "80"
source_addresses = concat(local.cloudflare_ipv4, local.cloudflare_ipv6)
}
# HTTPS — Cloudflare IPs for proxied domains + all IPs for registry (DNS-only)
inbound_rule {
protocol = "tcp"
port_range = "443"
source_addresses = concat(local.cloudflare_ipv4, local.cloudflare_ipv6)
source_addresses = ["0.0.0.0/0", "::/0"]
}
# Gitea SSH for git push/pull — your IP only
@@ -161,3 +162,13 @@ resource "cloudflare_record" "git_ssh" {
ttl = 3600
}
# DNS only — no Cloudflare proxy, for container registry (no 100MB upload limit)
resource "cloudflare_record" "registry" {
zone_id = data.cloudflare_zone.main.id
name = "registry"
type = "A"
value = digitalocean_droplet.gitea.ipv4_address
proxied = false
ttl = 3600
}