프로젝트 소스 공개
This commit is contained in:
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
readonly LOCAL_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
readonly PROJECT_ROOT="$(cd "$LOCAL_ROOT/../.." && pwd)"
|
||||
configuration_exports=$(/usr/bin/python3 "$PROJECT_ROOT/Tools/release_configuration.py" --shell)
|
||||
eval "$configuration_exports"
|
||||
readonly DEPLOY_HOST="$PROJECTQUINT_DEPLOY_HOST"
|
||||
readonly DEPLOY_KEY="$PROJECTQUINT_DEPLOY_KEY"
|
||||
readonly REMOTE_SOURCE="$PROJECTQUINT_REMOTE_SOURCE"
|
||||
readonly REMOTE_WEB_ROOT="/var/www/projectquint"
|
||||
readonly REMOTE_NGINX="/etc/nginx/sites-available/projectquint.conf"
|
||||
readonly SSH_ARGS=(-i "$DEPLOY_KEY" -o IdentitiesOnly=yes -o BatchMode=yes)
|
||||
readonly RSYNC_SSH=$(/usr/bin/python3 -c 'import shlex, sys; print(shlex.join(sys.argv[1:]))' ssh "${SSH_ARGS[@]}")
|
||||
|
||||
if [[ ! -f "$LOCAL_ROOT/package.json" || ! -d "$LOCAL_ROOT/dist" ]]; then
|
||||
printf 'ProjectQuint site build is missing. Run npm run build first.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh "${SSH_ARGS[@]}" "$DEPLOY_HOST" \
|
||||
"mkdir -p '$REMOTE_SOURCE' '$REMOTE_SOURCE/.deploy'"
|
||||
|
||||
rsync -a --delete \
|
||||
--exclude node_modules \
|
||||
--exclude dist \
|
||||
--exclude .astro \
|
||||
--exclude .deploy \
|
||||
-e "$RSYNC_SSH" \
|
||||
"$LOCAL_ROOT/" "$DEPLOY_HOST:$REMOTE_SOURCE/"
|
||||
|
||||
ssh "${SSH_ARGS[@]}" "$DEPLOY_HOST" \
|
||||
"mkdir -p '$REMOTE_SOURCE/.deploy/dist'"
|
||||
|
||||
rsync -a --delete \
|
||||
-e "$RSYNC_SSH" \
|
||||
"$LOCAL_ROOT/dist/" "$DEPLOY_HOST:$REMOTE_SOURCE/.deploy/dist/"
|
||||
|
||||
ssh "${SSH_ARGS[@]}" "$DEPLOY_HOST" \
|
||||
"sudo mkdir -p '$REMOTE_WEB_ROOT' &&
|
||||
sudo rsync -a --delete '$REMOTE_SOURCE/.deploy/dist/' '$REMOTE_WEB_ROOT/' &&
|
||||
sudo install -m 0644 '$REMOTE_SOURCE/ops/nginx/projectquint.conf' '$REMOTE_NGINX' &&
|
||||
sudo ln -sfn '$REMOTE_NGINX' /etc/nginx/sites-enabled/projectquint.conf &&
|
||||
sudo nginx -t &&
|
||||
sudo systemctl reload nginx"
|
||||
@@ -0,0 +1,97 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
server_name _;
|
||||
root /var/www/projectquint;
|
||||
index index.html;
|
||||
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
||||
add_header Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'none'" always;
|
||||
|
||||
location = /updates/latest.json {
|
||||
add_header Cache-Control "no-store" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location ^~ /downloads/ {
|
||||
alias /srv/projectquint/releases/;
|
||||
autoindex off;
|
||||
default_type application/octet-stream;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
||||
add_header Content-Disposition "attachment" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~* \.(?:css|js|otf|ttf|png|jpg|jpeg|webp|ico)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name projectquint.duckdns.org;
|
||||
root /var/www/projectquint;
|
||||
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://projectquint.duckdns.org$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
server_name projectquint.duckdns.org;
|
||||
root /var/www/projectquint;
|
||||
index index.html;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/projectquint.duckdns.org/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/projectquint.duckdns.org/privkey.pem;
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=15552000" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
||||
add_header Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'none'" always;
|
||||
|
||||
location = /updates/latest.json {
|
||||
add_header Cache-Control "no-store" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location ^~ /downloads/ {
|
||||
alias /srv/projectquint/releases/;
|
||||
autoindex off;
|
||||
default_type application/octet-stream;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
||||
add_header Content-Disposition "attachment" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~* \.(?:css|js|otf|ttf|png|jpg|jpeg|webp|ico)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user