mirror of
https://github.com/linuxserver/docker-unifi-network-application.git
synced 2025-03-05 20:59:58 -08:00
Merge 76bcaf322d
into 4caf784aac
This commit is contained in:
commit
947d7d2342
|
@ -17,6 +17,7 @@ RUN \
|
||||||
echo "**** install packages ****" && \
|
echo "**** install packages ****" && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install --no-install-recommends -y \
|
apt-get install --no-install-recommends -y \
|
||||||
|
gettext \
|
||||||
jsvc \
|
jsvc \
|
||||||
logrotate \
|
logrotate \
|
||||||
openjdk-17-jre-headless \
|
openjdk-17-jre-headless \
|
||||||
|
|
|
@ -17,6 +17,7 @@ RUN \
|
||||||
echo "**** install packages ****" && \
|
echo "**** install packages ****" && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install --no-install-recommends -y \
|
apt-get install --no-install-recommends -y \
|
||||||
|
gettext \
|
||||||
jsvc \
|
jsvc \
|
||||||
logrotate \
|
logrotate \
|
||||||
openjdk-17-jre-headless \
|
openjdk-17-jre-headless \
|
||||||
|
|
16
README.md
16
README.md
|
@ -183,15 +183,11 @@ services:
|
||||||
- PUID=1000
|
- PUID=1000
|
||||||
- PGID=1000
|
- PGID=1000
|
||||||
- TZ=Etc/UTC
|
- TZ=Etc/UTC
|
||||||
- MONGO_USER=unifi
|
- MONGO_URI=mongodb+srv://unifi:password@unifi.mongodb.net/unifi?retryWrites=true&w=majority&appName=unifi
|
||||||
- MONGO_PASS=
|
- STAT_MONGO_URI=mongodb+srv://unifi:password@unifi.mongodb.net/unifi_stats?retryWrites=true&w=majority&appName=unifi
|
||||||
- MONGO_HOST=unifi-db
|
|
||||||
- MONGO_PORT=27017
|
|
||||||
- MONGO_DBNAME=unifi
|
- MONGO_DBNAME=unifi
|
||||||
- MEM_LIMIT=1024 #optional
|
- MEM_LIMIT=1024 #optional
|
||||||
- MEM_STARTUP=1024 #optional
|
- MEM_STARTUP=1024 #optional
|
||||||
- MONGO_TLS= #optional
|
|
||||||
- MONGO_AUTHSOURCE= #optional
|
|
||||||
volumes:
|
volumes:
|
||||||
- /path/to/unifi-network-application/data:/config
|
- /path/to/unifi-network-application/data:/config
|
||||||
ports:
|
ports:
|
||||||
|
@ -215,15 +211,11 @@ docker run -d \
|
||||||
-e PUID=1000 \
|
-e PUID=1000 \
|
||||||
-e PGID=1000 \
|
-e PGID=1000 \
|
||||||
-e TZ=Etc/UTC \
|
-e TZ=Etc/UTC \
|
||||||
-e MONGO_USER=unifi \
|
-e MONGO_URI=mongodb+srv://unifi:password@unifi.mongodb.net/?retryWrites=true&w=majority&appName=unifi \
|
||||||
-e MONGO_PASS= \
|
-e STAT_MONGO_URI=mongodb+srv://unifi:password@unifi.mongodb.net/?retryWrites=true&w=majority&appName=unifi \
|
||||||
-e MONGO_HOST=unifi-db \
|
|
||||||
-e MONGO_PORT=27017 \
|
|
||||||
-e MONGO_DBNAME=unifi \
|
-e MONGO_DBNAME=unifi \
|
||||||
-e MEM_LIMIT=1024 `#optional` \
|
-e MEM_LIMIT=1024 `#optional` \
|
||||||
-e MEM_STARTUP=1024 `#optional` \
|
-e MEM_STARTUP=1024 `#optional` \
|
||||||
-e MONGO_TLS= `#optional` \
|
|
||||||
-e MONGO_AUTHSOURCE= `#optional` \
|
|
||||||
-p 8443:8443 \
|
-p 8443:8443 \
|
||||||
-p 3478:3478/udp \
|
-p 3478:3478/udp \
|
||||||
-p 10001:10001/udp \
|
-p 10001:10001/udp \
|
||||||
|
|
|
@ -30,19 +30,15 @@ param_ports:
|
||||||
|
|
||||||
param_usage_include_env: true
|
param_usage_include_env: true
|
||||||
param_env_vars:
|
param_env_vars:
|
||||||
- { env_var: "MONGO_USER", env_value: "unifi", desc: "Mongodb Username. Only evaluated on first run. **Special characters must be [url encoded](https://en.wikipedia.org/wiki/Percent-encoding)**." }
|
- { env_var: "MONGO_URI", env_value: "unifi", desc: "MongoDB URI. Only evaluated on first run." }
|
||||||
- { env_var: "MONGO_PASS", env_value: "", desc: "Mongodb Password. Only evaluated on first run. **Special characters must be [url encoded](https://en.wikipedia.org/wiki/Percent-encoding)**." }
|
- { env_var: "STAT_MONGO_URI", env_value: "", desc: "MongoDB stat URI. Only evaluated on first run." }
|
||||||
- { env_var: "MONGO_HOST", env_value: "unifi-db", desc: "Mongodb Hostname. Only evaluated on first run." }
|
- { env_var: "MONGO_DBNAME", env_value: "unifi", desc: "MongoDB Database Name (stats DB is automatically suffixed with `_stat`). Only evaluated on first run." }
|
||||||
- { env_var: "MONGO_PORT", env_value: "27017", desc: "Mongodb Port. Only evaluated on first run." }
|
|
||||||
- { env_var: "MONGO_DBNAME", env_value: "unifi", desc: "Mongodb Database Name (stats DB is automatically suffixed with `_stat`). Only evaluated on first run." }
|
|
||||||
|
|
||||||
# optional container parameters
|
# optional container parameters
|
||||||
opt_param_usage_include_env: true
|
opt_param_usage_include_env: true
|
||||||
opt_param_env_vars:
|
opt_param_env_vars:
|
||||||
- { env_var: "MEM_LIMIT", env_value: "1024", desc: "Optionally change the Java memory limit (in Megabytes). Set to `default` to reset to default" }
|
- { env_var: "MEM_LIMIT", env_value: "1024", desc: "Optionally change the Java memory limit (in Megabytes). Set to `default` to reset to default" }
|
||||||
- { env_var: "MEM_STARTUP", env_value: "1024", desc: "Optionally change the Java initial/minimum memory (in Megabytes). Set to `default` to reset to default" }
|
- { env_var: "MEM_STARTUP", env_value: "1024", desc: "Optionally change the Java initial/minimum memory (in Megabytes). Set to `default` to reset to default" }
|
||||||
- { env_var: "MONGO_TLS", env_value: "", desc: "Mongodb enable [TLS](https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.tls). Only evaluated on first run." }
|
|
||||||
- { env_var: "MONGO_AUTHSOURCE", env_value: "", desc: "Mongodb [authSource](https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.authSource). For Atlas set to `admin`.Defaults to `MONGO_DBNAME`.Only evaluated on first run." }
|
|
||||||
|
|
||||||
opt_param_usage_include_ports: true
|
opt_param_usage_include_ports: true
|
||||||
opt_param_ports:
|
opt_param_ports:
|
||||||
|
@ -57,24 +53,24 @@ app_setup_block_enabled: true
|
||||||
app_setup_block: |
|
app_setup_block: |
|
||||||
After setup, the web UI is available at https://ip:8443. The application can be configured, or a backup restored, using the first run wizard.
|
After setup, the web UI is available at https://ip:8443. The application can be configured, or a backup restored, using the first run wizard.
|
||||||
|
|
||||||
**This container requires an external mongodb database instance.**
|
**This container requires an external MongoDB database instance.**
|
||||||
|
|
||||||
### Setting Up Your External Database
|
### Setting Up Your External Database
|
||||||
|
|
||||||
Starting with version 8.1 of Unifi Network Application, mongodb 3.6 through 7.0 are supported.
|
Starting with version 8.1 of Unifi Network Application, MongoDB 3.6 through 7.0 are supported.
|
||||||
|
|
||||||
**Make sure you pin your database image version and do not use `latest`, as mongodb does not support automatic upgrades between major versions.**
|
**Make sure you pin your database image version and do not use `latest`, as MongoDB does not support automatic upgrades between major versions.**
|
||||||
|
|
||||||
**MongoDB >4.4 on X86_64 Hardware needs a CPU with AVX support. Some lower end Intel CPU models like Celeron and Pentium (before Tiger-Lake) more Details: [Advanced Vector Extensions - Wikipedia](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX) don't support AVX, but you can still use MongoDB 4.4.**
|
**MongoDB >4.4 on X86_64 Hardware needs a CPU with AVX support. Some lower end Intel CPU models like Celeron and Pentium (before Tiger-Lake) more Details: [Advanced Vector Extensions - Wikipedia](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX) don't support AVX, but you can still use MongoDB 4.4.**
|
||||||
|
|
||||||
If you are using the [official mongodb container](https://hub.docker.com/_/mongo/) in Version >=6, you can create your user using an `init-mongo.js` file with the following contents:
|
If you are using the [official MongoDB container](https://hub.docker.com/_/mongo/) in Version >=6, you can create your user using an `init-mongo.js` file with the following contents:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
db.getSiblingDB("MONGO_DBNAME").createUser({user: "MONGO_USER", pwd: "MONGO_PASS", roles: [{role: "dbOwner", db: "MONGO_DBNAME"}]});
|
db.getSiblingDB("MONGO_DBNAME").createUser({user: "MONGO_USER", pwd: "MONGO_PASS", roles: [{role: "dbOwner", db: "MONGO_DBNAME"}]});
|
||||||
db.getSiblingDB("MONGO_DBNAME_stat").createUser({user: "MONGO_USER", pwd: "MONGO_PASS", roles: [{role: "dbOwner", db: "MONGO_DBNAME_stat"}]});
|
db.getSiblingDB("MONGO_DBNAME_stat").createUser({user: "MONGO_USER", pwd: "MONGO_PASS", roles: [{role: "dbOwner", db: "MONGO_DBNAME_stat"}]});
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using mongodb < 6.0, you can create a `init-mongo.sh` file with the following contents:
|
If you are using MongoDB < 6.0, you can create a `init-mongo.sh` file with the following contents:
|
||||||
```sh
|
```sh
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
@ -124,7 +120,7 @@ app_setup_block: |
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
*Note that the init script method will only work on first run. If you start the Mongodb container without an init script it will generate test data automatically and you will have to manually create your databases, or restart with a clean `/data/db` volume and an init script mounted.*
|
*Note that the init script method will only work on first run. If you start the MongoDB container without an init script it will generate test data automatically and you will have to manually create your databases, or restart with a clean `/data/db` volume and an init script mounted.*
|
||||||
|
|
||||||
*If you are using the init JS method do not also set `MONGO_INITDB_ROOT_USERNAME`, `MONGO_INITDB_ROOT_PASSWORD`, or any other "INITDB" values as they will cause conflicts. Setting these variables for the .sh file is necessary*
|
*If you are using the init JS method do not also set `MONGO_INITDB_ROOT_USERNAME`, `MONGO_INITDB_ROOT_PASSWORD`, or any other "INITDB" values as they will cause conflicts. Setting these variables for the .sh file is necessary*
|
||||||
|
|
||||||
|
@ -161,6 +157,7 @@ app_setup_block: |
|
||||||
|
|
||||||
# changelog
|
# changelog
|
||||||
changelogs:
|
changelogs:
|
||||||
- { date: "04.03.24:", desc: "Install from zip package instead of deb." }
|
- { date: "21.05.24:", desc: "Change environment variables" }
|
||||||
|
- { date: "04.02.24:", desc: "Install from zip package instead of deb." }
|
||||||
- { date: "17.10.23:", desc: "Add environment variables for TLS and authSource to support Atlas and new MongoDB versions." }
|
- { date: "17.10.23:", desc: "Add environment variables for TLS and authSource to support Atlas and new MongoDB versions." }
|
||||||
- { date: "05.09.23:", desc: "Initial release." }
|
- { date: "05.09.23:", desc: "Initial release." }
|
||||||
|
|
|
@ -41,6 +41,6 @@
|
||||||
# unifi.throughput.port=6789
|
# unifi.throughput.port=6789
|
||||||
#
|
#
|
||||||
db.mongo.local=false
|
db.mongo.local=false
|
||||||
db.mongo.uri=mongodb://~MONGO_USER~:~MONGO_PASS~@~MONGO_HOST~:~MONGO_PORT~/~MONGO_DBNAME~?tls=~MONGO_TLS~~MONGO_AUTHSOURCE~
|
db.mongo.uri=$MONGO_URI
|
||||||
statdb.mongo.uri=mongodb://~MONGO_USER~:~MONGO_PASS~@~MONGO_HOST~:~MONGO_PORT~/~MONGO_DBNAME~_stat?tls=~MONGO_TLS~~MONGO_AUTHSOURCE~
|
statdb.mongo.uri=$STAT_MONGO_URI
|
||||||
unifi.db.name=~MONGO_DBNAME~
|
unifi.db.name=$MONGO_DBNAME
|
||||||
|
|
|
@ -28,39 +28,11 @@ if [[ ! -L "/usr/lib/unifi/run" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -e /config/data/system.properties ]]; then
|
if [[ ! -e /config/data/system.properties ]]; then
|
||||||
if [[ -z "${MONGO_HOST}" ]]; then
|
if [[ -z "${MONGO_URI}" || -z "${STAT_MONGO_URI}" || -z "${MONGO_DBNAME}" ]]; then
|
||||||
echo "*** No MONGO_HOST set, cannot configure database settings. ***"
|
echo "*** Required environment variables are not set, cannot configure database settings. ***"
|
||||||
sleep infinity
|
sleep infinity
|
||||||
else
|
else
|
||||||
echo "*** Waiting for MONGO_HOST ${MONGO_HOST} to be reachable. ***"
|
envsubst < /defaults/system.properties > /config/data/system.properties
|
||||||
DBCOUNT=0
|
|
||||||
while true; do
|
|
||||||
if nc -w1 "${MONGO_HOST}" "${MONGO_PORT}" >/dev/null 2>&1; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
DBCOUNT=$((DBCOUNT+1))
|
|
||||||
if [[ ${DBCOUNT} -gt 6 ]]; then
|
|
||||||
echo "*** Defined MONGO_HOST ${MONGO_HOST} is not reachable, cannot proceed. ***"
|
|
||||||
sleep infinity
|
|
||||||
fi
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
sed -i "s/~MONGO_USER~/${MONGO_USER}/" /defaults/system.properties
|
|
||||||
sed -i "s/~MONGO_HOST~/${MONGO_HOST}/" /defaults/system.properties
|
|
||||||
sed -i "s/~MONGO_PORT~/${MONGO_PORT}/" /defaults/system.properties
|
|
||||||
sed -i "s/~MONGO_DBNAME~/${MONGO_DBNAME}/" /defaults/system.properties
|
|
||||||
sed -i "s/~MONGO_PASS~/${MONGO_PASS}/" /defaults/system.properties
|
|
||||||
if [[ "${MONGO_TLS,,}" = "true" ]]; then
|
|
||||||
sed -i "s/~MONGO_TLS~/true/" /defaults/system.properties
|
|
||||||
else
|
|
||||||
sed -i "s/~MONGO_TLS~/false/" /defaults/system.properties
|
|
||||||
fi
|
|
||||||
if [[ -z "${MONGO_AUTHSOURCE}" ]]; then
|
|
||||||
sed -i "s/~MONGO_AUTHSOURCE~//" /defaults/system.properties
|
|
||||||
else
|
|
||||||
sed -i "s/~MONGO_AUTHSOURCE~/\&authSource=${MONGO_AUTHSOURCE}/" /defaults/system.properties
|
|
||||||
fi
|
|
||||||
cp /defaults/system.properties /config/data
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue