chore: add ansible backend docker frontend-prep

This commit is contained in:
2026-01-21 13:05:13 +01:00
parent 5a280b6b01
commit 943fe4de7d
14930 changed files with 2341433 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
[Unit]
Description=Backend Golang API
After=network.target
[Service]
User={{ user_owner }}
WorkingDirectory={{ backend_dir }}
ExecStart={{ backend_binary }}
Restart=always
[Install]
WantedBy=multi-user.target
+14
View File
@@ -0,0 +1,14 @@
[Unit]
Description=Frontend React Production (Vite)
After=network.target
[Service]
User={{ user_owner }}
Group={{ user_owner }}
WorkingDirectory={{ nginx_frontend_path }}
ExecStart=/usr/bin/npm run preview -- --port {{ frontend_port }}
Restart=always
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
+79
View File
@@ -0,0 +1,79 @@
upstream backend {
server 127.0.0.1:{{ backend_port }} max_fails=3 fail_timeout=30s;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name {{ nginx_domain }};
root {{ nginx_frontend_path }}/dist;
index index.html;
access_log /var/log/nginx/{{ nginx_app_name }}.access.log;
error_log /var/log/nginx/{{ nginx_app_name }}.error.log;
client_max_body_size {{ nginx_max_body_size }};
location /api/ {
limit_except GET POST PUT DELETE PATCH OPTIONS {
deny all;
}
proxy_pass http://backend/;
proxy_http_version 1.1;
proxy_set_header Connection "";
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;
proxy_connect_timeout {{ nginx_proxy_timeout }}s;
proxy_send_timeout {{ nginx_proxy_timeout }}s;
proxy_read_timeout {{ nginx_proxy_timeout }}s;
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 8 4k;
proxy_no_cache 1;
proxy_cache_bypass 1;
}
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
location ~* \.(css|js)$ {
expires {{ nginx_cache_static_duration }};
add_header Cache-Control "public, immutable";
access_log off;
}
location ~* \.(jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires {{ nginx_cache_media_duration }};
add_header Cache-Control "public, immutable";
access_log off;
}
location = /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~* (\.env|\.git|package\.json|package-lock\.json|yarn\.lock)$ {
deny all;
}
}
+25
View File
@@ -0,0 +1,25 @@
[Unit]
Description=Serveo Tunnel Service
After=network-online.target nginx.service
Wants=network-online.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory={{directory}}
ExecStart=/usr/bin/ssh \
-o ServerAliveInterval=60 \
-o ServerAliveCountMax=3 \
-o ExitOnForwardFailure=yes \
-o StrictHostKeyChecking=no \
-R {{nginx_app_name}}:80:{{nginx_domain}}:80 \
serveo.net
Restart=always
RestartSec=10
StandardOutput=append:{{tunnel_log}}
StandardError=append:{{tunnel_log_error}}
[Install]
WantedBy=multi-user.target