Documenta la struttura del repository, l'architettura dei tre servizi (app, nginx, certbot), le convenzioni e i comandi comuni in .junie/guidelines.md. Co-authored-by: Junie <junie@jetbrains.com>
4.2 KiB
4.2 KiB
Project Guidelines
Overview
This repository is not an application codebase — it is a Docker-based deployment/infrastructure configuration for exposing a Java web application behind an Nginx reverse proxy with automatic TLS certificate management via Let's Encrypt / Certbot.
The real website this is used for is www.elenabaracchini.it, but the configuration is written to be
reusable for any domain (placeholders use example.com).
Primary documentation (in Italian) lives in README.md. Keep it in sync with any changes.
Repository Layout
.
├── docker-compose.yml # Orchestrates the 3 services: app, nginx, certbot
├── init-letsencrypt.sh # First-time certificate bootstrap script
├── renew-certificates.sh # Interactive manual renewal helper
├── certbot-entrypoint.sh # Certbot container entrypoint (auto-renew loop OR passthrough)
├── nginx/
│ ├── nginx.conf # Global Nginx config (http block, gzip, logging)
│ └── conf.d/
│ └── app.conf # Virtual host: HTTP→HTTPS redirect + HTTPS reverse proxy
└── README.md # Full setup/usage/troubleshooting guide (Italian)
Architecture
app: the Java web application container (imageyour-java-app:latest, placeholder). Not exposed directly; only reachable through Nginx on the internalapp-network. Listens on port8080.nginx: reverse proxy (nginx:alpine), the only service bound to host ports80/443. Mounts config read-only and the shared Let's Encrypt volumes read-only.certbot:certbot/certbot:latestdriven bycertbot-entrypoint.sh.- No args → runs the auto-renewal loop (renew check every 12h).
- With args → execs the given
certbotcommand (used bydocker-compose run --rm certbot ...).
- Shared volumes:
certbot-webroot,certbot-certs,certbot-lib,certbot-logsconnect certbot and nginx for ACME challenges and certificate files.
Conventions
- Comments & docs are written in Italian. Match this language when editing scripts, config comments, and the README.
- Shell scripts use
#!/bin/bash(exceptcertbot-entrypoint.sh, which targets the Alpine shell with#!/bin/sh— keep it POSIX-compatible). Scripts useset -e. - Domain references: use
example.comas the placeholder in committed config. The real domain (elenabaracchini.it) is substituted at runtime byinit-letsencrypt.sh. - Nginx config is split: global settings in
nginx.conf, per-site server blocks inconf.d/*.conf. - Preserve the existing security posture in
app.conf(TLS 1.2/1.3, HSTS, security headers, OCSP stapling) when making changes.
Common Commands
# First-time certificate setup (use staging=1 for testing to avoid rate limits)
./init-letsencrypt.sh <domain> <email> [0|1]
# Full stack up / down
docker-compose up -d
docker-compose down
# Validate & reload nginx without downtime
docker-compose exec nginx nginx -t
docker-compose exec nginx nginx -s reload
# Certificate management
docker-compose run --rm certbot certificates
docker-compose run --rm certbot renew --dry-run
./renew-certificates.sh
# Logs
docker-compose logs -f nginx
docker-compose logs -f app
docker-compose logs certbot
Validation
There is no build or test suite. Validate changes by:
docker-compose config— verify the compose file parses.docker-compose exec nginx nginx -t— validate Nginx config syntax (requires nginx running).- Use Let's Encrypt staging (
--staging/init-letsencrypt.sh ... 1) before production to avoid hitting rate limits (50 certs/domain/week, 5 duplicates/week).
Things to Watch Out For
- Do not expose
appports directly on the host; traffic must flow through Nginx. - Never commit secrets (JWT secrets, DB passwords, etc.) — pass them via environment variables.
- When changing the domain, remember both
app.confserver blocks and the Let's Encrypt cert paths (/etc/letsencrypt/live/<domain>/...) must match. README.mdcurrently contains unresolved Git merge conflict markers (<<<<<<<,=======,>>>>>>>) around the file-structure section — resolve these if you touch that area.