Add basic Unifi Network Application deployment

- Write initial docker-compose.yml for Unifi containers
- Create a template for initializing MongoDB databases
- Add README with setup instructions for the initial environment
This commit is contained in:
Kris Lamoureux 2024-06-29 21:22:52 -04:00
commit 03c9d835dc
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
5 changed files with 118 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env
init-mongo.js

12
LICENSE Normal file
View File

@ -0,0 +1,12 @@
Copyright (C) 2024 by Kris Lamoureux <kris@lamoureux.io>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

65
README.md Normal file
View File

@ -0,0 +1,65 @@
# UniFi Network Server Deployment
This project provides a simple setup for self-hosting a UniFi Network Server
inside a container to manage Ubiquiti networking gear. It leverages the
community-managed linuxserver.io container to save time and engineering effort.
## Requirements
- Docker / Docker Compose
- `pwgen` (optional, for password generation)
## Compatibility
Starting with version 8.1 of UniFi Network Application, MongoDB versions 3.6
through 7.0 are supported.
## Quick Start
Follow these steps to get your UniFi Network Server up and running.
1. Clone this repository and navigate to the project directory
2. Copy the example MongoDB initialization script
```txt
cp example-init-mongo.js init-mongo.js
```
3. Change the default password to a random string
```txt
sed -i "s/changeme/$(pwgen -s 32 1)/g" init-mongo.js
```
Note: This command requires `pwgen`. If you don't have it installed, you can
manually edit the file and replace "changeme" with a strong password of your
choice.
4. Set the following environment variables in the `.env` file
- `UNIFI_VERSION`: The desired UniFi Network Application version
- `MONGO_VERSION`: The desired MongoDB version
- `MONGO_PASS`: The password you set in step 3
5. Start the containers using Docker Compose:
```txt
docker-compose up -d
```
## Version Selection
### UniFi Network Application
It's recommended to install the
[latest UniFi version](https://github.com/linuxserver/docker-unifi-network-application/releases),
preferably by specifying the version number. You can omit the `-lsXX` suffix if desired.
### MongoDB
It's highly recommended to use a specific version tag for
[MongoDB](https://www.mongodb.com/try/download/community) since there are no
automatic upgrades between major versions.
**Note:** Modern MongoDB relies on AVX support. You might encounter issues with
pre-Tiger Lake Celeron and Pentium CPUs on versions after 4.4. For non-AVX
systems, you can use version 4.4.
## Additional Information
For more details and configuration options, please refer to the
[linuxserver/docker-unifi-network-application](https://docs.linuxserver.io/images/docker-unifi-network-application/)
documentation.
## License
This project is free software under the [Zero-Clause BSD](LICENSE).

31
docker-compose.yml Normal file
View File

@ -0,0 +1,31 @@
services:
app:
image: ${UNIFI_IMAGE:-linuxserver/unifi-network-application}:${UNIFI_VERSION:?}
container_name: ${UNIFI_NAME:-unifi}
environment:
PUID: 1000
PGID: 1000
TZ: ${TIMEZONE:-America/New_York}
MONGO_HOST: db
MONGO_PORT: 27017
MONGO_DBNAME: ${MONGO_DBNAME:-unifi}
MONGO_USER: ${MONGO_USER:-unifi}
MONGO_PASS: ${MONGO_PASS:?}
volumes:
- app:/config
ports:
- 8443:8443
- 3478:3478/udp
- 10001:10001/udp
- 8080:8080
db:
image: ${MONGO_IMAGE:-mongo}:${MONGO_VERSION:?}
container_name: ${MONGO_NAME:-unifi-db}
volumes:
- db:/data/db
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
volumes:
db:
app:

8
example-init-mongo.js Normal file
View File

@ -0,0 +1,8 @@
db.getSiblingDB("unifi").createUser({
user: "unifi",
pwd: "changeme",
roles: [
{ role: "dbOwner", db: "unifi" },
{ role: "dbOwner", db: "unifi_stat" }
]
});