Compare commits
4 Commits
4686991b2f
...
689148fc22
| Author | SHA1 | Date | |
|---|---|---|---|
| 689148fc22 | |||
| 5d4dfd4d15 | |||
| 74636dc619 | |||
| 69556f63eb |
38
.env
38
.env
@@ -1,21 +1,41 @@
|
|||||||
# Immagine Docker da usare
|
# Immagine Docker da usare
|
||||||
NEXTERM_IMAGE=germannewsmaker/nexterm:latest
|
IMAGE=germannewsmaker/nexterm:latest
|
||||||
|
|
||||||
# Nome del container
|
# Nome del container
|
||||||
NEXTERM_CONTAINER_NAME=nexterm
|
CONTAINER_NAME=nexterm
|
||||||
|
|
||||||
# Politica di riavvio (no | always | unless-stopped | on-failure)
|
# Politica di riavvio (no | always | unless-stopped | on-failure)
|
||||||
NEXTERM_RESTART_POLICY=unless-stopped
|
RESTART_POLICY=unless-stopped
|
||||||
|
|
||||||
# Porte host/container
|
# Porta esposta sull'host
|
||||||
NEXTERM_PORT_HOST=8080
|
PORT=8485
|
||||||
|
|
||||||
# Percorso dati persistenti sul filesystem locale
|
# Percorso dati persistenti sul filesystem locale
|
||||||
NEXTERM_DATA_DIR=./nexterm_data
|
DATA_DIR=./nexterm_data
|
||||||
|
|
||||||
# Timezone del container
|
# Timezone (condivisa da tutti i servizi)
|
||||||
NEXTERM_TZ=Europe/Rome
|
TZ=Europe/Rome
|
||||||
|
|
||||||
# Chiave di cifratura usata da Nexterm (obbligatoria)
|
# Chiave di cifratura usata da Nexterm (obbligatoria)
|
||||||
# Deve essere una stringa esadecimale di 64 caratteri (32 byte).
|
# Deve essere una stringa esadecimale di 64 caratteri (32 byte).
|
||||||
NEXTERM_ENCRYPTION_KEY=4c4c18e819265ede62496d41dc6511ee4ec107ed0f6115a5d60856ed08ca933e
|
ENCRYPTION_KEY=crea_una_chiave_esadecimale_di_64_caratteri_per_la_cifratura
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Watchtower - aggiornamento automatico delle immagini Docker
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Immagine Watchtower
|
||||||
|
WATCHTOWER_IMAGE=containrrr/watchtower:latest
|
||||||
|
|
||||||
|
# Nome del container Watchtower
|
||||||
|
WATCHTOWER_CONTAINER_NAME=watchtower
|
||||||
|
|
||||||
|
# Rimozione automatica delle vecchie immagini dopo l'aggiornamento
|
||||||
|
WATCHTOWER_CLEANUP=true
|
||||||
|
|
||||||
|
# Schedule cron (secondi minuti ore giorni mese giorno_settimana)
|
||||||
|
# Default: ogni giorno alle 03:00
|
||||||
|
WATCHTOWER_SCHEDULE=0 0 3 * * *
|
||||||
|
|
||||||
|
# Livello log notifiche (panic | fatal | error | warn | info | debug | trace)
|
||||||
|
WATCHTOWER_NOTIFICATIONS_LEVEL=warn
|
||||||
|
|||||||
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
### Windows
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
105
Makefile
Normal file
105
Makefile
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
.DEFAULT_GOAL := help
|
||||||
|
ENV_FILE := .env
|
||||||
|
PLACEHOLDER := crea_una_chiave_esadecimale_di_64_caratteri_per_la_cifratura
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Rileva OS per generazione chiave
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
KEYGEN = powershell -NoProfile -Command \
|
||||||
|
"$$b = New-Object byte[] 32; \
|
||||||
|
[System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($$b); \
|
||||||
|
($$b | ForEach-Object { $$_.ToString('x2') }) -join ''"
|
||||||
|
else
|
||||||
|
KEYGEN = openssl rand -hex 32
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Legge ENCRYPTION_KEY dal .env per validazione
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
-include $(ENV_FILE)
|
||||||
|
export
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Targets
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help: ## Mostra questo messaggio di aiuto
|
||||||
|
@echo ""
|
||||||
|
@echo " Nexterm - guida al deploy"
|
||||||
|
@echo ""
|
||||||
|
@echo " 1. make genkey — genera e scrive ENCRYPTION_KEY nel .env"
|
||||||
|
@echo " 2. make check — verifica prerequisiti e configurazione"
|
||||||
|
@echo " 3. make up — avvia i container"
|
||||||
|
@echo ""
|
||||||
|
@echo " Altri comandi:"
|
||||||
|
@awk 'BEGIN {FS = ":.*?## "}; /^[a-zA-Z_-]+:.*?## / {printf " %-14s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
.PHONY: genkey
|
||||||
|
genkey: ## Genera ENCRYPTION_KEY casuale e la scrive nel .env
|
||||||
|
$(eval NEW_KEY := $(shell $(KEYGEN)))
|
||||||
|
@if [ -z "$(NEW_KEY)" ]; then \
|
||||||
|
echo "ERRORE: generazione chiave fallita. Assicurati che openssl sia installato."; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
@powershell -NoProfile -Command \
|
||||||
|
"(Get-Content $(ENV_FILE)) -replace '$(PLACEHOLDER)|^ENCRYPTION_KEY=.*', \
|
||||||
|
{ if ($$_ -match '^ENCRYPTION_KEY=') { 'ENCRYPTION_KEY=$(NEW_KEY)' } else { $$_ } } \
|
||||||
|
| Set-Content $(ENV_FILE)"
|
||||||
|
else
|
||||||
|
@sed -i "s|^ENCRYPTION_KEY=.*|ENCRYPTION_KEY=$(NEW_KEY)|" $(ENV_FILE)
|
||||||
|
endif
|
||||||
|
@echo "ENCRYPTION_KEY aggiornata nel file $(ENV_FILE)."
|
||||||
|
|
||||||
|
.PHONY: check
|
||||||
|
check: ## Verifica prerequisiti e configurazione prima del deploy
|
||||||
|
@echo "==> Controllo Docker..."
|
||||||
|
@docker info > /dev/null 2>&1 || (echo "ERRORE: Docker non raggiungibile." && exit 1)
|
||||||
|
@echo " OK"
|
||||||
|
@echo "==> Controllo docker compose..."
|
||||||
|
@docker compose version > /dev/null 2>&1 || (echo "ERRORE: docker compose v2 non trovato." && exit 1)
|
||||||
|
@echo " OK"
|
||||||
|
@echo "==> Controllo file $(ENV_FILE)..."
|
||||||
|
@test -f $(ENV_FILE) || (echo "ERRORE: file $(ENV_FILE) non trovato." && exit 1)
|
||||||
|
@echo " OK"
|
||||||
|
@echo "==> Controllo ENCRYPTION_KEY..."
|
||||||
|
@if echo "$(ENCRYPTION_KEY)" | grep -qE '^[0-9a-fA-F]{64}$$'; then \
|
||||||
|
echo " OK"; \
|
||||||
|
else \
|
||||||
|
echo "ERRORE: ENCRYPTION_KEY non valida (deve essere hex di 64 caratteri)."; \
|
||||||
|
echo " Esegui: make genkey"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@echo ""
|
||||||
|
@echo "Tutto OK. Puoi eseguire: make up"
|
||||||
|
|
||||||
|
.PHONY: up
|
||||||
|
up: ## Avvia i container in background
|
||||||
|
docker compose --env-file $(ENV_FILE) up -d
|
||||||
|
|
||||||
|
.PHONY: down
|
||||||
|
down: ## Ferma e rimuove i container
|
||||||
|
docker compose --env-file $(ENV_FILE) down
|
||||||
|
|
||||||
|
.PHONY: restart
|
||||||
|
restart: ## Riavvia i container
|
||||||
|
docker compose --env-file $(ENV_FILE) restart
|
||||||
|
|
||||||
|
.PHONY: logs
|
||||||
|
logs: ## Segue i log di nexterm in tempo reale
|
||||||
|
docker compose --env-file $(ENV_FILE) logs -f nexterm
|
||||||
|
|
||||||
|
.PHONY: ps
|
||||||
|
ps: ## Mostra lo stato dei container
|
||||||
|
docker compose --env-file $(ENV_FILE) ps
|
||||||
|
|
||||||
|
.PHONY: pull
|
||||||
|
pull: ## Scarica le immagini aggiornate senza riavviare
|
||||||
|
docker compose --env-file $(ENV_FILE) pull
|
||||||
|
|
||||||
|
.PHONY: update
|
||||||
|
update: pull ## Aggiorna le immagini e ricrea i container
|
||||||
|
docker compose --env-file $(ENV_FILE) up -d --remove-orphans
|
||||||
56
README.md
56
README.md
@@ -18,17 +18,25 @@ Modifica il file `.env` in base alle tue esigenze.
|
|||||||
|
|
||||||
Variabili principali:
|
Variabili principali:
|
||||||
|
|
||||||
- `NEXTERM_IMAGE`: immagine Docker da usare
|
- `IMAGE`: immagine Docker da usare
|
||||||
- `NEXTERM_CONTAINER_NAME`: nome del container
|
- `CONTAINER_NAME`: nome del container nexterm
|
||||||
- `NEXTERM_RESTART_POLICY`: policy di riavvio
|
- `RESTART_POLICY`: policy di riavvio (condivisa da tutti i servizi)
|
||||||
- `NEXTERM_PORT_HOST`: porta esposta sull'host
|
- `PORT`: porta esposta sull'host
|
||||||
- `NEXTERM_PORT_CONTAINER`: porta interna del container
|
- `DATA_DIR`: directory dati persistenti
|
||||||
- `NEXTERM_DATA_DIR`: directory dati persistenti
|
- `TZ`: timezone condivisa da tutti i servizi
|
||||||
- `NEXTERM_TZ`: timezone del container
|
- `ENCRYPTION_KEY`: chiave di cifratura obbligatoria per Nexterm
|
||||||
- `NEXTERM_ENCRYPTION_KEY`: chiave di cifratura obbligatoria per Nexterm
|
|
||||||
|
|
||||||
> `NEXTERM_ENCRYPTION_KEY` deve essere una stringa esadecimale di **64 caratteri**.
|
> `ENCRYPTION_KEY` deve essere una stringa esadecimale di **64 caratteri**.
|
||||||
> Esempio rapido (PowerShell):
|
|
||||||
|
Variabili Watchtower:
|
||||||
|
|
||||||
|
- `WATCHTOWER_IMAGE`: immagine Docker da usare (default: `containrrr/watchtower:latest`)
|
||||||
|
- `WATCHTOWER_CONTAINER_NAME`: nome del container Watchtower
|
||||||
|
- `WATCHTOWER_CLEANUP`: rimuove le vecchie immagini dopo l'aggiornamento (`true`/`false`)
|
||||||
|
- `WATCHTOWER_SCHEDULE`: schedule cron a 6 campi per il controllo aggiornamenti (default: ogni giorno alle 03:00)
|
||||||
|
- `WATCHTOWER_NOTIFICATIONS_LEVEL`: livello di log (`warn` consigliato)
|
||||||
|
|
||||||
|
Esempio rapido (PowerShell):
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
$bytes = New-Object byte[] 32
|
$bytes = New-Object byte[] 32
|
||||||
@@ -36,7 +44,31 @@ $bytes = New-Object byte[] 32
|
|||||||
($bytes | ForEach-Object { $_.ToString('x2') }) -join ''
|
($bytes | ForEach-Object { $_.ToString('x2') }) -join ''
|
||||||
```
|
```
|
||||||
|
|
||||||
## Avvio
|
Esempio rapido (Linux/macOS):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
openssl rand -hex 32
|
||||||
|
```
|
||||||
|
|
||||||
|
## Avvio rapido con Make
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make genkey # genera e scrive ENCRYPTION_KEY nel .env
|
||||||
|
make check # verifica prerequisiti e configurazione
|
||||||
|
make up # avvia i container
|
||||||
|
```
|
||||||
|
|
||||||
|
Altri comandi disponibili:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make logs # segue i log di nexterm
|
||||||
|
make ps # stato dei container
|
||||||
|
make update # aggiorna le immagini e ricrea i container
|
||||||
|
make down # ferma e rimuove i container
|
||||||
|
make help # lista completa dei comandi
|
||||||
|
```
|
||||||
|
|
||||||
|
## Avvio manuale
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
@@ -51,7 +83,7 @@ docker compose logs -f nexterm
|
|||||||
|
|
||||||
Apri poi il browser su:
|
Apri poi il browser su:
|
||||||
|
|
||||||
- `http://localhost:${NEXTERM_PORT_HOST}`
|
- `http://localhost:${PORT}`
|
||||||
|
|
||||||
## Stop e rimozione
|
## Stop e rimozione
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,27 @@
|
|||||||
services:
|
services:
|
||||||
nexterm:
|
nexterm:
|
||||||
image: ${NEXTERM_IMAGE}
|
image: ${IMAGE}
|
||||||
container_name: ${NEXTERM_CONTAINER_NAME}
|
container_name: ${CONTAINER_NAME}
|
||||||
restart: ${NEXTERM_RESTART_POLICY}
|
restart: ${RESTART_POLICY}
|
||||||
ports:
|
ports:
|
||||||
- "${NEXTERM_PORT_HOST}:6989"
|
- "${PORT}:6989"
|
||||||
volumes:
|
volumes:
|
||||||
- ${NEXTERM_DATA_DIR}:/app/data
|
- ${DATA_DIR}:/app/data
|
||||||
environment:
|
environment:
|
||||||
- TZ=${NEXTERM_TZ}
|
- TZ=${TZ}
|
||||||
- ENCRYPTION_KEY=${NEXTERM_ENCRYPTION_KEY}
|
- ENCRYPTION_KEY=${ENCRYPTION_KEY}
|
||||||
|
labels:
|
||||||
|
- "com.centurylinklabs.watchtower.enable=true"
|
||||||
|
|
||||||
|
watchtower:
|
||||||
|
image: ${WATCHTOWER_IMAGE}
|
||||||
|
container_name: ${CONTAINER_NAME}_${WATCHTOWER_CONTAINER_NAME}
|
||||||
|
restart: ${RESTART_POLICY}
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
environment:
|
||||||
|
- TZ=${TZ}
|
||||||
|
- WATCHTOWER_CLEANUP=${WATCHTOWER_CLEANUP}
|
||||||
|
- WATCHTOWER_SCHEDULE=${WATCHTOWER_SCHEDULE}
|
||||||
|
- WATCHTOWER_LABEL_ENABLE=true
|
||||||
|
- WATCHTOWER_NOTIFICATIONS_LEVEL=${WATCHTOWER_NOTIFICATIONS_LEVEL}
|
||||||
Reference in New Issue
Block a user