315 lines
8.1 KiB
Markdown
315 lines
8.1 KiB
Markdown
# Deployment naar Dockge (Home Server)
|
|
|
|
Deze handleiding beschrijft hoe je de Activiteiten Inventaris applicatie deployt naar je home server met Dockge, Gitea en Nginx Proxy Manager.
|
|
|
|
## Overzicht
|
|
|
|
- **Gitea**: Lokale Git server voor versiebeheer
|
|
- **Dockge**: Docker Compose stack manager
|
|
- **Nginx Proxy Manager**: Reverse proxy met SSL
|
|
- **Domein**: poll.hausmans.cloud
|
|
|
|
---
|
|
|
|
## Stap 1: Repository aanmaken in Gitea
|
|
|
|
### 1.1 Lokale Git repository initialiseren
|
|
|
|
Voer deze commando's uit in de project directory op je ontwikkelmachine:
|
|
|
|
```bash
|
|
cd /Users/berthausmans/Documents/Development/questionnaire
|
|
|
|
# Git repository initialiseren
|
|
git init
|
|
|
|
# Alle bestanden toevoegen
|
|
git add .
|
|
|
|
# Eerste commit maken
|
|
git commit -m "Initial commit: Activiteiten Inventaris applicatie"
|
|
```
|
|
|
|
### 1.2 Repository aanmaken in Gitea
|
|
|
|
1. Open Gitea in je browser (bijv. `http://gitea.local:3000`)
|
|
2. Klik op **"+"** → **"New Repository"**
|
|
3. Vul in:
|
|
- **Repository Name**: `questionnaire`
|
|
- **Visibility**: Private (aanbevolen)
|
|
- **Initialize repository**: ❌ Niet aanvinken (we pushen bestaande code)
|
|
4. Klik op **"Create Repository"**
|
|
|
|
### 1.3 Code pushen naar Gitea
|
|
|
|
```bash
|
|
# Remote toevoegen (vervang met je Gitea URL)
|
|
git remote add origin http://gitea.local:3000/jouw-gebruiker/questionnaire.git
|
|
|
|
# Code pushen
|
|
git push -u origin main
|
|
```
|
|
|
|
> **Tip**: Als je branch `master` heet i.p.v. `main`:
|
|
> ```bash
|
|
> git branch -M main
|
|
> git push -u origin main
|
|
> ```
|
|
|
|
---
|
|
|
|
## Stap 2: Repository clonen op de server
|
|
|
|
SSH naar je Proxmox server en clone de repository:
|
|
|
|
```bash
|
|
# Ga naar de Dockge stacks directory
|
|
cd /opt/stacks
|
|
|
|
# Clone de repository van Gitea
|
|
git clone http://gitea.local:3000/jouw-gebruiker/questionnaire.git
|
|
```
|
|
|
|
> **Authenticatie**: Je wordt gevraagd om je Gitea gebruikersnaam en wachtwoord.
|
|
> Tip: Maak een Access Token aan in Gitea (Settings → Applications → Generate New Token)
|
|
|
|
---
|
|
|
|
## Stap 3: Stack aanmaken in Dockge
|
|
|
|
1. Open Dockge in je browser (bijv. `http://server-ip:5001`)
|
|
2. Klik op **"+ Compose"** om een nieuwe stack aan te maken
|
|
3. Geef de stack een naam: `questionnaire`
|
|
4. Plak de volgende `docker-compose.yml`:
|
|
|
|
```yaml
|
|
version: '3.8'
|
|
|
|
services:
|
|
app:
|
|
build: .
|
|
container_name: questionnaire
|
|
ports:
|
|
- "4000:4000"
|
|
environment:
|
|
- NODE_ENV=production
|
|
- PORT=4000
|
|
- SESSION_SECRET=${SESSION_SECRET}
|
|
- DB_PATH=/app/data/questionnaire.db
|
|
- DEFAULT_ADMIN_USER=${DEFAULT_ADMIN_USER:-admin}
|
|
- DEFAULT_ADMIN_PASS=${DEFAULT_ADMIN_PASS}
|
|
volumes:
|
|
- ./data:/app/data
|
|
restart: unless-stopped
|
|
networks:
|
|
- proxy
|
|
|
|
networks:
|
|
proxy:
|
|
external: true
|
|
```
|
|
|
|
5. Maak een `.env` bestand aan (via Dockge's Environment tab) met:
|
|
|
|
```env
|
|
SESSION_SECRET=jouw-super-geheime-sleutel-hier-minimaal-32-tekens
|
|
DEFAULT_ADMIN_USER=admin
|
|
DEFAULT_ADMIN_PASS=jouw-veilige-wachtwoord
|
|
```
|
|
|
|
> ⚠️ **Belangrijk**: Gebruik sterke, unieke waarden voor `SESSION_SECRET` en `DEFAULT_ADMIN_PASS`!
|
|
|
|
---
|
|
|
|
## Stap 3: Docker netwerk aanmaken (eenmalig)
|
|
|
|
Als je nog geen `proxy` netwerk hebt, maak deze aan via SSH op je server:
|
|
|
|
```bash
|
|
docker network create proxy
|
|
```
|
|
|
|
Dit netwerk wordt gebruikt om de applicatie te verbinden met Nginx Proxy Manager.
|
|
|
|
---
|
|
|
|
## Stap 4: Stack deployen
|
|
|
|
1. In Dockge, klik op **"Deploy"** of **"Up"**
|
|
2. Wacht tot de image is gebouwd en de container draait
|
|
3. Test of de applicatie werkt: `http://server-ip:4000`
|
|
|
|
---
|
|
|
|
## Stap 5: Nginx Proxy Manager configureren
|
|
|
|
1. Open Nginx Proxy Manager (bijv. `http://server-ip:81`)
|
|
2. Ga naar **Proxy Hosts** → **Add Proxy Host**
|
|
|
|
### Details tab:
|
|
|
|
| Veld | Waarde |
|
|
|------|--------|
|
|
| Domain Names | `poll.hausmans.cloud` |
|
|
| Scheme | `http` |
|
|
| Forward Hostname / IP | `questionnaire` (container naam) |
|
|
| Forward Port | `4000` |
|
|
| Block Common Exploits | ✅ |
|
|
| Websockets Support | ❌ (niet nodig) |
|
|
|
|
### SSL tab:
|
|
|
|
| Veld | Waarde |
|
|
|------|--------|
|
|
| SSL Certificate | Request a new SSL Certificate |
|
|
| Force SSL | ✅ |
|
|
| HTTP/2 Support | ✅ |
|
|
| HSTS Enabled | ✅ (optioneel) |
|
|
| Email Address | jouw@email.com |
|
|
| I Agree... | ✅ |
|
|
|
|
3. Klik op **Save**
|
|
|
|
---
|
|
|
|
## Stap 6: DNS configureren
|
|
|
|
Zorg dat je domein `poll.hausmans.cloud` naar je home IP-adres wijst:
|
|
|
|
| Type | Naam | Waarde |
|
|
|------|------|--------|
|
|
| A | poll | jouw-publieke-ip |
|
|
|
|
Of als je een dynamisch IP hebt, gebruik CNAME met een DynDNS service.
|
|
|
|
---
|
|
|
|
## Stap 7: Router port forwarding
|
|
|
|
Zorg dat je router poorten doorstuurt naar Nginx Proxy Manager:
|
|
|
|
| Externe poort | Interne poort | Protocol | Doel IP |
|
|
|--------------|---------------|----------|---------|
|
|
| 80 | 80 | TCP | NPM server IP |
|
|
| 443 | 443 | TCP | NPM server IP |
|
|
|
|
---
|
|
|
|
## Verificatie
|
|
|
|
1. Ga naar `https://poll.hausmans.cloud`
|
|
2. Je zou de login pagina moeten zien
|
|
3. Log in met je admin credentials
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### Container start niet
|
|
|
|
```bash
|
|
# Bekijk logs
|
|
docker logs questionnaire
|
|
|
|
# Of in Dockge, klik op de container en bekijk logs
|
|
```
|
|
|
|
### Database permissies
|
|
|
|
```bash
|
|
# Zorg dat de data directory schrijfbaar is
|
|
chmod 755 /opt/stacks/questionnaire/data
|
|
```
|
|
|
|
### Netwerk problemen
|
|
|
|
```bash
|
|
# Controleer of container in proxy netwerk zit
|
|
docker network inspect proxy
|
|
```
|
|
|
|
### NPM kan container niet bereiken
|
|
|
|
Zorg dat beide containers (questionnaire en NPM) in hetzelfde Docker netwerk zitten (`proxy`).
|
|
|
|
---
|
|
|
|
## Updates deployen
|
|
|
|
### Vanaf je ontwikkelmachine
|
|
|
|
```bash
|
|
cd /Users/berthausmans/Documents/Development/questionnaire
|
|
|
|
# Wijzigingen toevoegen en committen
|
|
git add .
|
|
git commit -m "Beschrijving van je wijzigingen"
|
|
|
|
# Pushen naar Gitea
|
|
git push
|
|
```
|
|
|
|
### Op de server (via SSH of Dockge terminal)
|
|
|
|
```bash
|
|
cd /opt/stacks/questionnaire
|
|
|
|
# Laatste wijzigingen ophalen
|
|
git pull
|
|
```
|
|
|
|
### In Dockge
|
|
|
|
1. Open de `questionnaire` stack
|
|
2. Klik op **"Down"** (stop de stack)
|
|
3. Klik op **"Rebuild"** om de image opnieuw te bouwen
|
|
4. Klik op **"Up"** om de stack te starten
|
|
|
|
> **Tip**: Je kunt stap 2-4 ook combineren met de "Recreate" optie als beschikbaar.
|
|
|
|
---
|
|
|
|
## Backup
|
|
|
|
De database wordt opgeslagen in `./data/questionnaire.db`. Maak regelmatig backups:
|
|
|
|
```bash
|
|
cp /opt/stacks/questionnaire/data/questionnaire.db ~/backups/questionnaire-$(date +%Y%m%d).db
|
|
```
|
|
|
|
---
|
|
|
|
## Volledige workflow samenvatting
|
|
|
|
```
|
|
┌─────────────────┐ git push ┌─────────────────┐
|
|
│ Ontwikkelmachine │ ─────────────► │ Gitea │
|
|
│ (lokaal) │ │ (lokaal netwerk)│
|
|
└─────────────────┘ └────────┬────────┘
|
|
│ git pull
|
|
▼
|
|
┌─────────────────┐
|
|
│ Dockge/Server │
|
|
│ (Proxmox) │
|
|
└────────┬────────┘
|
|
│ docker build
|
|
▼
|
|
┌─────────────────┐
|
|
│ Docker Container│
|
|
│ (port 4000) │
|
|
└────────┬────────┘
|
|
│
|
|
▼
|
|
┌─────────────────┐
|
|
│ Nginx Proxy Mgr │
|
|
│ + Let's Encrypt │
|
|
└────────┬────────┘
|
|
│
|
|
▼
|
|
┌─────────────────┐
|
|
│ Internet │
|
|
│ poll.hausmans.cloud
|
|
└─────────────────┘
|
|
```
|
|
|