From 465987829c26ae89042fdb692a82d37b248ae33c Mon Sep 17 00:00:00 2001 From: Sergio Date: Fri, 3 Apr 2026 22:09:41 +0200 Subject: [PATCH] afegit deploy.sh --- CLAUDE.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ deploy.sh | 32 +++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 CLAUDE.md create mode 100755 deploy.sh diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..2c47fe8 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,66 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +JAILGAMES is a static website for publishing and downloading indie games. Built with **Eleventy (11ty) v3** using Nunjucks templates, served via **Nginx in Docker**. The site language is Spanish. + +## Commands + +- `npm ci` — install dependencies +- `npm run serve` — local dev server on port 8080 (auto-rebuilds on changes) +- `npm run build` — generate static site into `_site/` +- `npm run clean` — delete `_site/` +- `docker compose up --build -d` — build and run locally via Docker on port 80 + +## Architecture + +**Static site generator (Eleventy)** configured in `.eleventy.js`: +- Input: `src/` — Output: `_site/` +- Templates: Nunjucks (`.njk`), data files: YAML +- Custom "games" collection built by reading all `src/games/*.yaml` files, sorted by `release_date` desc +- Custom filters: `dateFormat` (Spanish locale dates), `markdown` (markdown-it rendering) +- Passthrough copies: `static/logo` -> `logo`, `static/games` -> `games`, `downloads/`, `src/css`, `src/js` + +**Data-driven game pages:** Each game is a YAML file in `src/games/.yaml` with fields: name, slug, tagline, description, version, release_date, tags, logo, screenshots, downloads (per-platform), engine, players, genre, repo. The `src/game.njk` template uses Eleventy pagination to generate `/game//` pages from the games collection. + +**Templates hierarchy:** +- `base.njk` — HTML shell (head, header, footer, CSS/JS includes) +- `game-card.njk` — game card partial used on the homepage grid +- `game-page.njk` — full game detail page layout +- `index.njk` — homepage iterating `collections.games` + +**Static assets** live outside `src/`: `static/` for images, `downloads/` for game binaries. These are passed through to the build output and also mounted as Docker volumes for live updates without rebuilding. + +## Adding a New Game + +1. Create `src/games/.yaml` (copy from an existing game) +2. Add images to `static/games//` +3. Add downloadable files to `downloads//` +4. Ensure paths in the YAML match the actual files + +## Deployment + +- **Local Docker:** `docker compose up --build -d` (multi-stage Dockerfile: node build + nginx serve) +- **Production (esta máquina):** `./deploy.sh` — compila y copia a los volúmenes Docker persistentes +- **Production manual:** Uses `docker-compose.portainer.yml` with Traefik reverse proxy +- Domain: `jailgames.sustancia.synology.me` + +### deploy.sh + +Script para desplegar cambios en producción local. Ejecutar desde la raíz del proyecto: + +```bash +./deploy.sh +``` + +Lo que hace: +1. `npm ci` — instala dependencias +2. `npm run build` — compila el sitio en `_site/` +3. Copia `_site/` a `/var/volumes/web_jailgames/` (contenido HTML) +4. Copia `downloads/` a `/var/volumes/web_jailgames/downloads/` (binarios de juegos) +5. Copia `nginx.conf` a `/var/volumes/web_jailgames-nginx/jailgames.conf` +6. Recarga nginx en el contenedor `jailgames` (si está activo) + +Requiere `sudo` (escritura en `/var/volumes/`) y `docker` (para el reload de nginx). diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..0034486 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +SITE_VOL="/var/volumes/web_jailgames" +NGINX_VOL="/var/volumes/web_jailgames-nginx" + +cd "$SCRIPT_DIR" + +echo "==> Instalando dependencias..." +npm ci --silent + +echo "==> Compilando sitio..." +npm run build --silent + +echo "==> Copiando sitio a $SITE_VOL ..." +sudo rsync -a --delete _site/ "$SITE_VOL/" + +echo "==> Copiando descargas a $SITE_VOL/downloads/ ..." +sudo rsync -a downloads/ "$SITE_VOL/downloads/" + +echo "==> Copiando nginx.conf a $NGINX_VOL/jailgames.conf ..." +sudo cp nginx.conf "$NGINX_VOL/jailgames.conf" + +echo "==> Hecho. Recargando nginx en el contenedor..." +if docker exec jailgames nginx -s reload 2>/dev/null; then + echo " Nginx recargado." +else + echo " (contenedor 'jailgames' no encontrado o no activo, omitiendo reload)" +fi + +echo "==> Deploy completado."