Add UniFi Docker Compose setup
This commit is contained in:
6
.env.example
Normal file
6
.env.example
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
MONGO_ADMIN_USER=<mongo_admin_user>
|
||||||
|
MONGO_ADMIN_PASS=<mongo_admin_pwd>
|
||||||
|
|
||||||
|
MONGO_USER=unifi
|
||||||
|
MONGO_PASS=<unifi_pwd>
|
||||||
|
MONGO_DBNAME=unifi
|
||||||
16
.gitignore
vendored
Normal file
16
.gitignore
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Secrets
|
||||||
|
.env
|
||||||
|
|
||||||
|
# Persistent application data
|
||||||
|
config/
|
||||||
|
mongodb/
|
||||||
|
|
||||||
|
# Local backups and archives
|
||||||
|
*.tgz
|
||||||
|
*.tar.gz
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
# Logs and editor files
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
|
*.swp
|
||||||
96
README.md
Normal file
96
README.md
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# UniFi Network Controller
|
||||||
|
|
||||||
|
Docker Compose-installation av UniFi Network Application på Raspberry Pi 4.
|
||||||
|
|
||||||
|
## Plattform
|
||||||
|
|
||||||
|
- Raspberry Pi 4B, 4 GB RAM
|
||||||
|
- Raspberry Pi OS Lite 64-bit, Debian Trixie
|
||||||
|
- Docker och Docker Compose
|
||||||
|
- UniFi Network Application från LinuxServer.io
|
||||||
|
- MongoDB 4.4.18
|
||||||
|
|
||||||
|
MongoDB är låst till 4.4.18 eftersom senare MongoDB-versioner kräver
|
||||||
|
ARMv8.2-A, vilket Raspberry Pi 4 inte stöder.
|
||||||
|
|
||||||
|
## Filer
|
||||||
|
|
||||||
|
- `compose.yaml` – UniFi och MongoDB
|
||||||
|
- `init-mongo/init-mongo.sh` – skapar MongoDB-användare och rättigheter
|
||||||
|
- `.env.example` – exempel på obligatoriska miljövariabler
|
||||||
|
|
||||||
|
Följande lagras inte i Git:
|
||||||
|
|
||||||
|
- `.env`
|
||||||
|
- `config/`
|
||||||
|
- `mongodb/`
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
nano .env
|
||||||
|
chmod 600 .env
|
||||||
|
|
||||||
|
mkdir -p config mongodb
|
||||||
|
chmod 755 init-mongo/init-mongo.sh
|
||||||
|
|
||||||
|
docker compose pull
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
cat > README.md <<'EOF'
|
||||||
|
```
|
||||||
|
# UniFi Network Controller
|
||||||
|
|
||||||
|
Docker Compose-installation av UniFi Network Application på Raspberry Pi 4.
|
||||||
|
|
||||||
|
## Plattform
|
||||||
|
|
||||||
|
- Raspberry Pi 4B, 4 GB RAM
|
||||||
|
- Raspberry Pi OS Lite 64-bit, Debian Trixie
|
||||||
|
- Docker och Docker Compose
|
||||||
|
- UniFi Network Application från LinuxServer.io
|
||||||
|
- MongoDB 4.4.18
|
||||||
|
|
||||||
|
MongoDB är låst till 4.4.18 eftersom senare MongoDB-versioner kräver
|
||||||
|
ARMv8.2-A, vilket Raspberry Pi 4 inte stöder.
|
||||||
|
|
||||||
|
## Filer
|
||||||
|
|
||||||
|
- `compose.yaml` – UniFi och MongoDB
|
||||||
|
- `init-mongo/init-mongo.sh` – skapar MongoDB-användare och rättigheter
|
||||||
|
- `.env.example` – exempel på obligatoriska miljövariabler
|
||||||
|
|
||||||
|
Följande lagras inte i Git:
|
||||||
|
|
||||||
|
- `.env`
|
||||||
|
- `config/`
|
||||||
|
- `mongodb/`
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
nano .env
|
||||||
|
chmod 600 .env
|
||||||
|
|
||||||
|
mkdir -p config mongodb
|
||||||
|
chmod 755 init-mongo/init-mongo.sh
|
||||||
|
|
||||||
|
docker compose pull
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## Kontroll
|
||||||
|
docker compose ps
|
||||||
|
docker compose logs --tail=100 mongodb
|
||||||
|
docker compose logs --tail=100 unifi
|
||||||
|
|
||||||
|
## Webbgränssnitt:
|
||||||
|
|
||||||
|
https://<controller-ip>:8443
|
||||||
|
|
||||||
|
## Viktigt
|
||||||
|
|
||||||
|
MongoDB-port 27017 exponeras inte på LAN:et. Databasen är endast
|
||||||
|
åtkomlig från UniFi-containern via det interna Docker-nätverket.
|
||||||
65
compose.yaml
Normal file
65
compose.yaml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
services:
|
||||||
|
mongodb:
|
||||||
|
image: mongo:4.4.18
|
||||||
|
container_name: unifi-mongodb
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
environment:
|
||||||
|
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ADMIN_USER}
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ADMIN_PASS}
|
||||||
|
|
||||||
|
MONGO_USER: ${MONGO_USER}
|
||||||
|
MONGO_PASS: ${MONGO_PASS}
|
||||||
|
MONGO_DBNAME: ${MONGO_DBNAME}
|
||||||
|
MONGO_AUTHSOURCE: admin
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- ./mongodb:/data/db
|
||||||
|
- ./init-mongo/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh:ro
|
||||||
|
|
||||||
|
networks:
|
||||||
|
- unifi-internal
|
||||||
|
|
||||||
|
unifi:
|
||||||
|
image: lscr.io/linuxserver/unifi-network-application:latest
|
||||||
|
container_name: unifi
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- mongodb
|
||||||
|
|
||||||
|
environment:
|
||||||
|
PUID: 1002
|
||||||
|
PGID: 1002
|
||||||
|
TZ: Europe/Stockholm
|
||||||
|
|
||||||
|
MONGO_USER: ${MONGO_USER}
|
||||||
|
MONGO_PASS: ${MONGO_PASS}
|
||||||
|
MONGO_HOST: mongodb
|
||||||
|
MONGO_PORT: 27017
|
||||||
|
MONGO_DBNAME: ${MONGO_DBNAME}
|
||||||
|
MONGO_AUTHSOURCE: admin
|
||||||
|
|
||||||
|
MEM_LIMIT: 2048
|
||||||
|
MEM_STARTUP: 1024
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- ./config:/config
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "8443:8443"
|
||||||
|
- "8080:8080"
|
||||||
|
- "3478:3478/udp"
|
||||||
|
- "10001:10001/udp"
|
||||||
|
- "1900:1900/udp"
|
||||||
|
- "8843:8843"
|
||||||
|
- "8880:8880"
|
||||||
|
- "6789:6789"
|
||||||
|
- "5514:5514/udp"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
- unifi-internal
|
||||||
|
|
||||||
|
networks:
|
||||||
|
unifi-internal:
|
||||||
|
driver: bridge
|
||||||
25
init-mongo/init-mongo.sh
Executable file
25
init-mongo/init-mongo.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if which mongosh > /dev/null 2>&1; then
|
||||||
|
mongo_init_bin='mongosh'
|
||||||
|
else
|
||||||
|
mongo_init_bin='mongo'
|
||||||
|
fi
|
||||||
|
|
||||||
|
"${mongo_init_bin}" <<EOF
|
||||||
|
use ${MONGO_AUTHSOURCE}
|
||||||
|
|
||||||
|
db.auth("${MONGO_INITDB_ROOT_USERNAME}", "${MONGO_INITDB_ROOT_PASSWORD}")
|
||||||
|
|
||||||
|
db.createUser({
|
||||||
|
user: "${MONGO_USER}",
|
||||||
|
pwd: "${MONGO_PASS}",
|
||||||
|
roles: [
|
||||||
|
"clusterMonitor",
|
||||||
|
{ db: "${MONGO_DBNAME}", role: "dbOwner" },
|
||||||
|
{ db: "${MONGO_DBNAME}_stat", role: "dbOwner" },
|
||||||
|
{ db: "${MONGO_DBNAME}_audit", role: "dbOwner" },
|
||||||
|
{ db: "${MONGO_DBNAME}_restore", role: "dbOwner" }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
EOF
|
||||||
Reference in New Issue
Block a user