diff --git a/docker-compose/.env.letsencrypt b/docker-compose/.env.letsencrypt index 573bfa7..8596eb4 100644 --- a/docker-compose/.env.letsencrypt +++ b/docker-compose/.env.letsencrypt @@ -1,5 +1,6 @@ -# Image tags COMPOSE_PROJECT_NAME=openwifi + +# Image tags OWGW_TAG=master OWGWUI_TAG=main OWSEC_TAG=main @@ -8,10 +9,12 @@ OWPROV_TAG=main OWPROVUI_TAG=main OWANALYTICS_TAG=main OWSUB_TAG=main + KAFKA_TAG=2.8.0-debian-10-r43 ZOOKEEPER_TAG=3.8 +POSTGRESQL_TAG=15.0 ACMESH_TAG=latest -TRAEFIK_TAG=latest +TRAEFIK_TAG=v3.1.0 # Microservice root/config directories OWGW_ROOT=/owgw-data @@ -38,3 +41,4 @@ INTERNAL_OWANALYTICS_HOSTNAME=owanalytics.wlan.local INTERNAL_RTTYS_HOSTNAME=rttys.wlan.local INTERNAL_OWSUB_HOSTNAME=owsub.wlan.local SDKHOSTNAME= +#SDKHOSTNAME=openwifi.example.com diff --git a/docker-compose/.env.selfsigned b/docker-compose/.env.selfsigned index c9b52c1..8e3aef1 100644 --- a/docker-compose/.env.selfsigned +++ b/docker-compose/.env.selfsigned @@ -1,5 +1,6 @@ -# Image tags COMPOSE_PROJECT_NAME=openwifi + +# Image tags OWGW_TAG=master OWGWUI_TAG=main OWSEC_TAG=main @@ -8,8 +9,10 @@ OWPROV_TAG=main OWPROVUI_TAG=main OWANALYTICS_TAG=main OWSUB_TAG=main + KAFKA_TAG=2.8.0-debian-10-r43 ZOOKEEPER_TAG=3.8 +POSTGRESQL_TAG=15.0 ACMESH_TAG=latest TRAEFIK_TAG=latest diff --git a/docker-compose/README.md b/docker-compose/README.md index 070b491..486ca96 100644 --- a/docker-compose/README.md +++ b/docker-compose/README.md @@ -1,10 +1,10 @@ # OpenWifi SDK Docker Compose + ### Overview With the provided Docker Compose files you can instantiate a deployment of the OpenWifi microservices and related components. The repository contains a self-signed certificate and a TIP-signed gateway certificate which are valid for the `*.wlan.local` domain. You also have the possibility to either generate and use Let's Encrypt certs or provide your own certificates. Furthermore the deployments are split by whether Traefik is used as a reverse proxy/load balancer in front of the microservices or if they are exposed directly on the host. The advantage of using the deployments with Traefik is that you can use Let's Encrypt certs (automatic certificate generation and renewal) and you have the ability to scale specific containers to multiple replicas. The repository also contains a separate Docker Compose deployment to set up the [OWLS microservice](https://github.com/Telecominfraproject/wlan-cloud-owls) and related components for running a load simulation test against an existing controller. - [Non-LB deployment with self-signed certificates](#non-lb-deployment-with-self-signed-certificates) - [Non-LB deployment with own certificates](#non-lb-deployment-with-own-certificates) -- [Non-LB deployment with PostgreSQL](#non-lb-deployment-with-postgresql) - [LB deployment with self-signed certificates](#lb-deployment-with-self-signed-certificates) - [LB deployment with Let's Encrypt certificates](#lb-deployment-with-letsencrypt-certificates) - [OWLS deployment with self-signed certificates](owls/README.md) @@ -13,13 +13,90 @@ The repository also contains a separate Docker Compose deployment to set up the ### Configuration Config files for the microservices are generated on every startup based on the environment variables in the microservice specific env files. For an overview of the supported configuration properties have a look into these files. For an explanation of the configuration properties please see the README in the respective microservice repository. Be aware that local changes to the config files will be overwritten on every startup if `TEMPLATE_CONFIG` is set to `true` in the microservice env files. If you want to bind mount your own config file or make local changes, please set this variable to `false`. + #### Required password changing on the first startup One important action that must be done before using the deployment is changing password for the default user in owsec as described in [owsec docs](https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/tree/main#changing-default-password). Please use these docs to find the actions that must be done **after** the deployment in order to start using your deployment. + ### Ports Every OpenWifi service is exposed via a separate port either directly on the host or through Traefik. For an overview of the exposed ports have a look into the deployment specific Docker Compose file. If you use your own certificates, you can also configure different hostnames for the microservices. Please note that the OWProv-UI is exposed on port `8080(HTTP)/8443(HTTPS)` by default. + ### owsec templates and wwwassets On the startup of owsec directories for wwwassets and mailer templates are created from the base files included in Docker image. After the initial startup you may edit those files as you wish in the [owsec-data/persist](./owsec-data/persist) directory. + +## PostgreSQL +PostgreSQL is used by default for the database for all components. +The following variables may be set in the env files. It is highly recommended that you change the DB passwords to some random string. The defaults are shown here. + +### owgw.env +| Variable | Value/Description | +| ---------------------------------- | ----------------- | +| `STORAGE_TYPE` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owgw` | +| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owgw` | +| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owgw` | + +### owsec.env +| Variable | Value/Description | +| ---------------------------------- | ----------------- | +| `STORAGE_TYPE` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owsec` | +| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owsec` | +| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owsec` | + +### owfms.env +| Variable | Value/Description | +| ---------------------------------- | ----------------- | +| `STORAGE_TYPE` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owfms` | +| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owfms` | +| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owfms` | + +### owprov.env +| Variable | Value/Description | +| ---------------------------------- | ----------------- | +| `STORAGE_TYPE` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owprov` | +| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owprov` | +| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owprov` | + +### owanalytics.env +| Variable | Value/Description | +| ---------------------------------- | ----------------- | +| `STORAGE_TYPE` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | +| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owanalytics` | +| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owanalytics` | +| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owanalytics` | + +### postgresql.env +| Variable | Value | +| --------------------------| ------------- | +| `POSTGRES_PASSWORD` | `postgres` | +| `POSTGRES_USER` | `postgres` | +| `OWGW_DB` | `owgw` | +| `OWGW_DB_USER` | `owgw` | +| `OWGW_DB_PASSWORD` | `owgw` | +| `OWSEC_DB` | `owsec` | +| `OWSEC_DB_USER` | `owsec` | +| `OWSEC_DB_PASSWORD` | `owsec` | +| `OWFMS_DB` | `owfms` | +| `OWFMS_DB_USER` | `owfms` | +| `OWFMS_DB_PASSWORD` | `owfms` | +| `OWPROV_DB` | `owprov` | +| `OWPROV_DB_USER` | `owprov` | +| `OWPROV_DB_PASSWORD` | `owprov` | +| `OWANALYTICS_DB` | `owanalytics` | +| `OWANALYTICS_DB_USER` | `owanalytics` | +| `OWANALYTICS_DB_PASSWORD` | `owanalytics` | +| `OWSUB_DB` | `owsub` | +| `OWSUB_DB_USER` | `owsub` | +| `OWSUB_DB_PASSWORD` | `owsub` | + ## Non-LB deployment with self-signed certificates 1. Switch into the project directory with `cd docker-compose/`. 2. Add an entry for `openwifi.wlan.local` in your hosts file which points to `127.0.0.1` or whatever the IP of the host running the deployment is. @@ -34,9 +111,11 @@ export OWSEC="openwifi.wlan.local:16001" export FLAGS="-s --cacert /docker-compose/certs/restapi-ca.pem" ``` ⚠️**Note**: When deploying with self-signed certificates you can not use the 'Trace' and 'Connect' features in the UI since the AP will throw a TLS error. Please use the Let's Encrypt deployment or provide your own valid certificates if you want to use these features. + ## Non-LB deployment with own certificates 1. Switch into the project directory with `cd docker-compose/`. Copy your websocket and REST API certificates into the `certs/` directory. Make sure to reference the certificates accordingly in the service config if you use different file names or if you want to use different certificates for the respective microservices. 2. Adapt the following hostname and URI variables according to your environment: + ### .env | Variable | Description | | ------------------------------- | ---------------------------------------------------------------------------------- | @@ -46,6 +125,7 @@ export FLAGS="-s --cacert /docker-comp | `INTERNAL_OWPROV_HOSTNAME` | Set this to your OWProv hostname, for example `owprov.example.com`. | | `INTERNAL_OWANALYTICS_HOSTNAME` | Set this to your OWAnalytics hostname, for example `owanalytics.example.com`. | | `INTERNAL_OWSUB_HOSTNAME` | Set this to your OWSub hostname, for example `owsub.example.com`. | + ### owgw.env | Variable | Description | | ---------------------------------------- | ----------------------------------------------------------------------------------- | @@ -54,29 +134,35 @@ export FLAGS="-s --cacert /docker-comp | `SYSTEM_URI_PRIVATE`,`SYSTEM_URI_PUBLIC` | Set this to your OWGW REST API URL, for example `https://owgw.example.com:16002`. | | `RTTY_SERVER` | Set this to your OWGW RTTYS hostname, for example `owgw.example.com`. | | `SYSTEM_URI_UI` | Set this to your OWGW-UI URL, for example `https://owgw-ui.example.com`. | + ### owgw-ui.env | Variable | Description | | --------------------------- | -------------------------------------------------------------------------- | | `REACT_APP_UCENTRALSEC_URL` | Set this to your OWSec URL, for example `https://owsec.example.com:16001`. | + ### owsec.env | Variable | Description | | ---------------------------------------- | ----------------------------------------------------------------------------------- | | `SYSTEM_URI_PRIVATE`,`SYSTEM_URI_PUBLIC` | Set this to your OWSec URL, for example `https://owsec.example.com:16001`. | | `SYSTEM_URI_UI` | Set this to your OWGW-UI URL, for example `https://owgw-ui.example.com`. | + ### owfms.env | Variable | Description | | ---------------------------------------- | ----------------------------------------------------------------------------------- | | `SYSTEM_URI_PRIVATE`,`SYSTEM_URI_PUBLIC` | Set this to your OWFms URL, for example `https://owfms.example.com:16004`. | | `SYSTEM_URI_UI` | Set this to your OWGW-UI URL, for example `https://owgw-ui.example.com`. | + ### owprov.env | Variable | Description | | ---------------------------------------- | ------------------------------------------------------------------------------------- | | `SYSTEM_URI_PRIVATE`,`SYSTEM_URI_PUBLIC` | Set this to your OWProv URL, for example `https://owprov.example.com:16005`. | | `SYSTEM_URI_UI` | Set this to your OWGW-UI URL, for example `https://owgw-ui.example.com`. | + ### owprov-ui.env | Variable | Description | | --------------------------- | -------------------------------------------------------------------------- | | `REACT_APP_UCENTRALSEC_URL` | Set this to your OWSec URL, for example `https://owsec.example.com:16001`. | + ### owanalytics.env | Variable | Description | | ---------------------------------------- | -------------------------------------------------------------------------------------- | @@ -86,79 +172,15 @@ export FLAGS="-s --cacert /docker-comp 3. Spin up the deployment with `docker-compose up -d`. 4. Check if the containers are up and running with `docker-compose ps`. 5. Login to the UI and and follow the instructions to change your default password. -## Non-LB deployment with PostgreSQL -1. Switch into the project directory with `cd docker-compose/`. -2. Set the following variables in the env files and make sure to uncomment the lines. It is highly recommended that you change the DB passwords to some random string. -### owgw.env -| Variable | Value/Description | -| ---------------------------------- | ----------------- | -| `STORAGE_TYPE` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owgw` | -| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owgw` | -| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owgw` | -### owsec.env -| Variable | Value/Description | -| ---------------------------------- | ----------------- | -| `STORAGE_TYPE` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owsec` | -| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owsec` | -| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owsec` | -### owfms.env -| Variable | Value/Description | -| ---------------------------------- | ----------------- | -| `STORAGE_TYPE` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owfms` | -| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owfms` | -| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owfms` | -### owprov.env -| Variable | Value/Description | -| ---------------------------------- | ----------------- | -| `STORAGE_TYPE` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owprov` | -| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owprov` | -| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owprov` | -### owanalytics.env -| Variable | Value/Description | -| ---------------------------------- | ----------------- | -| `STORAGE_TYPE` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_HOST` | `postgresql` | -| `STORAGE_TYPE_POSTGRESQL_USERNAME` | `owanalytics` | -| `STORAGE_TYPE_POSTGRESQL_PASSWORD` | `owanalytics` | -| `STORAGE_TYPE_POSTGRESQL_DATABASE` | `owanalytics` | -### postgresql.env -| Variable | Value | -| --------------------------| ------------- | -| `POSTGRES_PASSWORD` | `postgres` | -| `POSTGRES_USER` | `postgres` | -| `OWGW_DB` | `owgw` | -| `OWGW_DB_USER` | `owgw` | -| `OWGW_DB_PASSWORD` | `owgw` | -| `OWSEC_DB` | `owsec` | -| `OWSEC_DB_USER` | `owsec` | -| `OWSEC_DB_PASSWORD` | `owsec` | -| `OWFMS_DB` | `owfms` | -| `OWFMS_DB_USER` | `owfms` | -| `OWFMS_DB_PASSWORD` | `owfms` | -| `OWPROV_DB` | `owprov` | -| `OWPROV_DB_USER` | `owprov` | -| `OWPROV_DB_PASSWORD` | `owprov` | -| `OWANALYTICS_DB` | `owanalytics` | -| `OWANALYTICS_DB_USER` | `owanalytics` | -| `OWANALYTICS_DB_PASSWORD` | `owanalytics` | -| `OWSUB_DB` | `owsub` | -| `OWSUB_DB_USER` | `owsub` | -| `OWSUB_DB_PASSWORD` | `owsub` | -3. Depending on whether you want to use [self-signed certificates](#non-lb-deployment-with-self-signed-certificates) or [provide your own](#non-lb-deployment-with-own-certificates), follow the instructions of the according deployment model. Spin up the deployment with `docker-compose -f docker-compose.yml -f docker-compose.postgresql.yml up -d`. It is recommended to create an alias for this deployment model with `alias docker-compose-postgresql="docker-compose -f docker-compose.yml -f docker-compose.postgresql.yml"`. + ## LB deployment with self-signed certificates Follow the same instructions as for the self-signed deployment without Traefik. The only difference is that you have to spin up the deployment with `docker-compose -f docker-compose.lb.selfsigned.yml --env-file .env.selfsigned up -d`. Make sure to specify the Compose and the according .env file every time you're working with the deployment or create an alias, for example `alias docker-compose-lb-selfsigned="docker-compose -f docker-compose.lb.selfsigned.yml --env-file .env.selfsigned"`. You also have the possibility to scale specific services to a specified number of instances with `docker-compose-lb-selfsigned up -d --scale SERVICE=NUM`, where `SERVICE` is the service name as defined in the Compose file. + ## LB deployment with Let's Encrypt certificates For the Let's Encrypt challenge to work you need a public IP address. The hostname which you set in the `$SDKHOSTNAME` env variable has to resolve to this IP address to pass the HTTP-01 challenge (https://letsencrypt.org/docs/challenge-types/#http-01-challenge). 1. Switch into the project directory with `cd docker-compose/`. 2. Adapt the following hostname and URI variables according to your environment. + ### .env.letsencrypt | Variable | Description | | ------------- | ---------------------------------------------------------------------------------------------------------- | @@ -189,24 +211,29 @@ For the Let's Encrypt challenge to work you need a public IP address. The hostna | ------------------- | ----------------------------------------------------------------------------- | | `SYSTEM_URI_PUBLIC` | Set this to your OWFms URL, for example `https://openwifi.example.com:16004`. | | `SYSTEM_URI_UI` | Set this to your OWGW-UI URL, for example `https://openwifi.example.com`. | + ### owprov.env -| Variable | Description | +| Variable | Description | | -------------------- | ------------------------------------------------------------------------------ | | `SYSTEM_URI_PUBLIC` | Set this to your OWProv URL, for example `https://openwifi.example.com:16005`. | | `SYSTEM_URI_UI` | Set this to your OWGW-UI URL, for example `https://openwifi.example.com`. | + ### owprov-ui.env | Variable | Description | | --------------------------- | ----------------------------------------------------------------------------- | | `REACT_APP_UCENTRALSEC_URL` | Set this to your OWSec URL, for example `https://openwifi.example.com:16001`. | + ### owanalytics.env | Variable | Description | | -------------------- | ----------------------------------------------------------------------------------- | | `SYSTEM_URI_PUBLIC` | Set this to your OWAnalytics URL, for example `https://openwifi.example.com:16009`. | | `SYSTEM_URI_UI` | Set this to your OWProv-UI URL, for example `https://openwifi.example.com`. | + ### owsub.env | Variable | Description | | -------------------- | ----------------------------------------------------------------------------- | | `SYSTEM_URI_PUBLIC` | Set this to your OWSub URL, for example `https://openwifi.example.com:16006`. | + | `SYSTEM_URI_UI` | Set this to your OWGW-UI URL, for example `https://openwifi.example.com`. | ### traefik.env | Variable | Description | diff --git a/docker-compose/cloudformation/openwifi-cloudsdk-docker-compose.yml b/docker-compose/cloudformation/openwifi-cloudsdk-docker-compose.yml index 4d95001..39bf4f0 100644 --- a/docker-compose/cloudformation/openwifi-cloudsdk-docker-compose.yml +++ b/docker-compose/cloudformation/openwifi-cloudsdk-docker-compose.yml @@ -205,8 +205,6 @@ Resources: docker-compose.lb.letsencrypt.yml --env-file .env.letsencrypt" alias docker-compose-lb-selfsigned="docker-compose -f \ docker-compose.lb.selfsigned.yml --env-file .env.selfsigned" - alias docker-compose-postgresql="docker-compose -f \ - docker-compose.yml -f docker-compose.postgresql.yml" mode: "000644" owner: "root" group: "root" diff --git a/docker-compose/docker-compose.lb.letsencrypt.yml b/docker-compose/docker-compose.lb.letsencrypt.yml index e808a27..41cec41 100644 --- a/docker-compose/docker-compose.lb.letsencrypt.yml +++ b/docker-compose/docker-compose.lb.letsencrypt.yml @@ -17,6 +17,8 @@ volumes: driver: local kafka_data: driver: local + postgresql_data: + driver: local letsencrypt_certs: driver: local @@ -36,6 +38,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owgw"] restart: unless-stopped volumes: - owgw_data:${OWGW_ROOT}/persist @@ -72,6 +77,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owsec"] restart: unless-stopped volumes: - owsec_data:${OWSEC_ROOT}/persist @@ -89,6 +97,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owfms"] restart: unless-stopped volumes: - owfms_data:${OWFMS_ROOT}/persist @@ -106,6 +117,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owprov"] restart: unless-stopped volumes: - owprov_data:${OWPROV_ROOT} @@ -138,6 +152,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owanalytics"] restart: unless-stopped volumes: - owanalytics_data:${OWANALYTICS_ROOT} @@ -155,6 +172,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owsub"] restart: unless-stopped volumes: - owsub_data:${OWSUB_ROOT} @@ -247,3 +267,26 @@ services: - "1812:1812/udp" - "1813:1813/udp" - "3799:3799/udp" + + postgresql: + image: "postgres:${POSTGRESQL_TAG}" + networks: + openwifi: + command: + - "postgres" + - "-c" + - "max_connections=400" + - "-c" + - "shared_buffers=20MB" + env_file: + - postgresql.env + restart: unless-stopped + volumes: + - postgresql_data:/var/lib/postgresql/data + - ./postgresql/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres -d owsub"] + interval: 10s + retries: 5 + start_period: 30s + timeout: 10s diff --git a/docker-compose/docker-compose.lb.selfsigned.yml b/docker-compose/docker-compose.lb.selfsigned.yml index 5eadd44..42a8f4d 100644 --- a/docker-compose/docker-compose.lb.selfsigned.yml +++ b/docker-compose/docker-compose.lb.selfsigned.yml @@ -17,6 +17,8 @@ volumes: driver: local kafka_data: driver: local + postgresql_data: + driver: local networks: openwifi: @@ -34,6 +36,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owgw"] restart: unless-stopped volumes: - owgw_data:${OWGW_ROOT}/persist @@ -45,8 +50,6 @@ services: owgw-ui: image: "tip-tip-wlan-cloud-ucentral.jfrog.io/owgw-ui:${OWGWUI_TAG}" - env_file: - - owgw-ui.env networks: openwifi: aliases: @@ -72,6 +75,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owsec"] restart: unless-stopped volumes: - owsec_data:${OWSEC_ROOT}/persist @@ -89,6 +95,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owfms"] restart: unless-stopped volumes: - owfms_data:${OWFMS_ROOT}/persist @@ -106,6 +115,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owprov"] restart: unless-stopped volumes: - owprov_data:${OWPROV_ROOT} @@ -138,6 +150,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owanalytics"] restart: unless-stopped volumes: - owanalytics_data:${OWANALYTICS_ROOT} @@ -155,6 +170,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owsub"] restart: unless-stopped volumes: - owsub_data:${OWSUB_ROOT} @@ -241,3 +259,26 @@ services: - "1812:1812/udp" - "1813:1813/udp" - "3799:3799/udp" + + postgresql: + image: "postgres:${POSTGRESQL_TAG}" + networks: + openwifi: + command: + - "postgres" + - "-c" + - "max_connections=400" + - "-c" + - "shared_buffers=20MB" + env_file: + - postgresql.env + restart: unless-stopped + volumes: + - postgresql_data:/var/lib/postgresql/data + - ./postgresql/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres -d owsub"] + interval: 10s + retries: 5 + start_period: 30s + timeout: 10s diff --git a/docker-compose/docker-compose.postgresql.yml b/docker-compose/docker-compose.postgresql.yml deleted file mode 100644 index c8865f5..0000000 --- a/docker-compose/docker-compose.postgresql.yml +++ /dev/null @@ -1,75 +0,0 @@ -volumes: - postgresql_data: - driver: local - -services: - owgw: - depends_on: - init-kafka: - condition: service_completed_successfully - postgresql: - condition: service_healthy - command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owgw"] - - owsec: - depends_on: - init-kafka: - condition: service_completed_successfully - postgresql: - condition: service_healthy - command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owsec"] - - owfms: - depends_on: - init-kafka: - condition: service_completed_successfully - postgresql: - condition: service_healthy - command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owfms"] - - owprov: - depends_on: - init-kafka: - condition: service_completed_successfully - postgresql: - condition: service_healthy - command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owprov"] - - owanalytics: - depends_on: - init-kafka: - condition: service_completed_successfully - postgresql: - condition: service_healthy - command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owanalytics"] - - owsub: - depends_on: - init-kafka: - condition: service_completed_successfully - postgresql: - condition: service_healthy - command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owsub"] - - postgresql: - image: "postgres:${POSTGRESQL_TAG}" - networks: - openwifi: - command: - - "postgres" - - "-c" - - "max_connections=400" - - "-c" - - "shared_buffers=20MB" - env_file: - - postgresql.env - restart: unless-stopped - volumes: - - postgresql_data:/var/lib/postgresql/data - - ./postgresql/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh - healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres -d owgw"] - interval: 10s - retries: 5 - start_period: 30s - timeout: 10s diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 5686851..9a1f581 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -5,6 +5,8 @@ volumes: driver: local kafka_data: driver: local + postgresql_data: + driver: local networks: openwifi: @@ -21,6 +23,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owgw"] restart: unless-stopped volumes: - "./owgw_data:${OWGW_ROOT}" @@ -73,6 +78,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owsec"] restart: unless-stopped volumes: - "./owsec_data:${OWSEC_ROOT}" @@ -92,6 +100,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owfms"] restart: unless-stopped volumes: - "./owfms_data:${OWFMS_ROOT}" @@ -111,6 +122,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owprov"] restart: unless-stopped volumes: - "./owprov_data:${OWPROV_ROOT}" @@ -152,6 +166,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owanalytics"] restart: unless-stopped volumes: - "./owanalytics_data:${OWANALYTICS_ROOT}" @@ -171,6 +188,9 @@ services: depends_on: init-kafka: condition: service_completed_successfully + postgresql: + condition: service_healthy + command: ["./wait-for-postgres.sh", "postgresql", "/openwifi/owsub"] restart: unless-stopped volumes: - "./owsub_data:${OWSUB_ROOT}" @@ -220,3 +240,26 @@ services: --create --if-not-exists --topic $$topic --replication-factor 1 \ --partitions 1 --bootstrap-server kafka:9092 done && echo "Successfully created Kafka topics, exiting." && exit 0 + + postgresql: + image: "postgres:${POSTGRESQL_TAG}" + networks: + openwifi: + command: + - "postgres" + - "-c" + - "max_connections=400" + - "-c" + - "shared_buffers=20MB" + env_file: + - postgresql.env + restart: unless-stopped + volumes: + - postgresql_data:/var/lib/postgresql/data + - ./postgresql/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres -d owsub"] + interval: 10s + retries: 5 + start_period: 30s + timeout: 10s diff --git a/docker-compose/owanalytics.env b/docker-compose/owanalytics.env index aa94a1f..83ff047 100644 --- a/docker-compose/owanalytics.env +++ b/docker-compose/owanalytics.env @@ -23,17 +23,19 @@ SYSTEM_DATA=$OWANALYTICS_ROOT/persist SYSTEM_URI_PRIVATE=https://owanalytics.wlan.local:17009 SYSTEM_URI_PUBLIC=https://openwifi.wlan.local:16009 SYSTEM_URI_UI=https://openwifi.wlan.local + #SECURITY_RESTAPI_DISABLE=false #KAFKA_ENABLE=true KAFKA_BROKERLIST=kafka:9092 -#STORAGE_TYPE=sqlite -#STORAGE_TYPE_POSTGRESQL_HOST=localhost -#STORAGE_TYPE_POSTGRESQL_USERNAME=owanalytics -#STORAGE_TYPE_POSTGRESQL_PASSWORD=owanalytics -#STORAGE_TYPE_POSTGRESQL_DATABASE=owanalytics -#STORAGE_TYPE_POSTGRESQL_PORT=5432 +STORAGE_TYPE=postgresql +STORAGE_TYPE_POSTGRESQL_HOST=postgresql +STORAGE_TYPE_POSTGRESQL_USERNAME=owanalytics +STORAGE_TYPE_POSTGRESQL_PASSWORD=owanalytics +STORAGE_TYPE_POSTGRESQL_DATABASE=owanalytics +STORAGE_TYPE_POSTGRESQL_PORT=5432 #STORAGE_TYPE_MYSQL_HOST=localhost #STORAGE_TYPE_MYSQL_USERNAME=owanalytics #STORAGE_TYPE_MYSQL_PASSWORD=owanalytics #STORAGE_TYPE_MYSQL_DATABASE=owanalytics #STORAGE_TYPE_MYSQL_PORT=3306 +#STORAGE_TYPE=sqlite diff --git a/docker-compose/owfms.env b/docker-compose/owfms.env index b286475..48611ca 100644 --- a/docker-compose/owfms.env +++ b/docker-compose/owfms.env @@ -29,14 +29,15 @@ S3_KEY=AKIAUG47UZG7R6SRLD7F #S3_BUCKET_URI=ucentral-ap-firmware.s3.amazonaws.com #KAFKA_ENABLE=true KAFKA_BROKERLIST=kafka:9092 -#STORAGE_TYPE=sqlite -#STORAGE_TYPE_POSTGRESQL_HOST=localhost -#STORAGE_TYPE_POSTGRESQL_USERNAME=owfms -#STORAGE_TYPE_POSTGRESQL_PASSWORD=owfms -#STORAGE_TYPE_POSTGRESQL_DATABASE=owfms -#STORAGE_TYPE_POSTGRESQL_PORT=5432 +STORAGE_TYPE=postgresql +STORAGE_TYPE_POSTGRESQL_HOST=postgresql +STORAGE_TYPE_POSTGRESQL_USERNAME=owfms +STORAGE_TYPE_POSTGRESQL_PASSWORD=owfms +STORAGE_TYPE_POSTGRESQL_DATABASE=owfms +STORAGE_TYPE_POSTGRESQL_PORT=5432 #STORAGE_TYPE_MYSQL_HOST=localhost #STORAGE_TYPE_MYSQL_USERNAME=owfms #STORAGE_TYPE_MYSQL_PASSWORD=owfms #STORAGE_TYPE_MYSQL_DATABASE=owfms #STORAGE_TYPE_MYSQL_PORT=3306 +#STORAGE_TYPE=sqlite diff --git a/docker-compose/owgw.env b/docker-compose/owgw.env index 968bad8..5586a44 100644 --- a/docker-compose/owgw.env +++ b/docker-compose/owgw.env @@ -56,15 +56,17 @@ RADIUS_PROXY_ENABLE=true #RADIUS_PROXY_COA_PORT=3799 #KAFKA_ENABLE=true KAFKA_BROKERLIST=kafka:9092 -#STORAGE_TYPE=sqlite -#STORAGE_TYPE_POSTGRESQL_HOST=localhost -#STORAGE_TYPE_POSTGRESQL_USERNAME=owgw -#STORAGE_TYPE_POSTGRESQL_PASSWORD=owgw -#STORAGE_TYPE_POSTGRESQL_DATABASE=owgw -#STORAGE_TYPE_POSTGRESQL_PORT=5432 +STORAGE_TYPE=postgresql +STORAGE_TYPE_POSTGRESQL_HOST=postgresql +STORAGE_TYPE_POSTGRESQL_USERNAME=owgw +STORAGE_TYPE_POSTGRESQL_PASSWORD=owgw +STORAGE_TYPE_POSTGRESQL_DATABASE=owgw +STORAGE_TYPE_POSTGRESQL_PORT=5432 #STORAGE_TYPE_MYSQL_HOST=localhost #STORAGE_TYPE_MYSQL_USERNAME=owgw #STORAGE_TYPE_MYSQL_PASSWORD=owgw #STORAGE_TYPE_MYSQL_DATABASE=owgw #STORAGE_TYPE_MYSQL_PORT=3306 +#STORAGE_TYPE=sqlite + #CERTIFICATES_ALLOWMISMATCH=false diff --git a/docker-compose/owprov.env b/docker-compose/owprov.env index a895329..9ff13ba 100644 --- a/docker-compose/owprov.env +++ b/docker-compose/owprov.env @@ -26,14 +26,15 @@ SYSTEM_URI_UI=https://openwifi.wlan.local #SECURITY_RESTAPI_DISABLE=false #KAFKA_ENABLE=true KAFKA_BROKERLIST=kafka:9092 -#STORAGE_TYPE=sqlite -#STORAGE_TYPE_POSTGRESQL_HOST=localhost -#STORAGE_TYPE_POSTGRESQL_USERNAME=owprov -#STORAGE_TYPE_POSTGRESQL_PASSWORD=owprov -#STORAGE_TYPE_POSTGRESQL_DATABASE=owprov -#STORAGE_TYPE_POSTGRESQL_PORT=5432 +STORAGE_TYPE=postgresql +STORAGE_TYPE_POSTGRESQL_HOST=postgresql +STORAGE_TYPE_POSTGRESQL_USERNAME=owprov +STORAGE_TYPE_POSTGRESQL_PASSWORD=owprov +STORAGE_TYPE_POSTGRESQL_DATABASE=owprov +STORAGE_TYPE_POSTGRESQL_PORT=5432 #STORAGE_TYPE_MYSQL_HOST=localhost #STORAGE_TYPE_MYSQL_USERNAME=owprov #STORAGE_TYPE_MYSQL_PASSWORD=owprov #STORAGE_TYPE_MYSQL_DATABASE=owprov #STORAGE_TYPE_MYSQL_PORT=3306 +#STORAGE_TYPE=sqlite diff --git a/docker-compose/owsec.env b/docker-compose/owsec.env index bd4f68d..952637e 100644 --- a/docker-compose/owsec.env +++ b/docker-compose/owsec.env @@ -35,14 +35,15 @@ SYSTEM_URI_UI=https://openwifi.wlan.local KAFKA_BROKERLIST=kafka:9092 #DOCUMENT_POLICY_ACCESS=$OWSEC_ROOT/wwwassets/access_policy.html #DOCUMENT_POLICY_PASSWORD=$OWSEC_ROOT/wwwassets/password_policy.html -#STORAGE_TYPE=sqlite -#STORAGE_TYPE_POSTGRESQL_HOST=localhost -#STORAGE_TYPE_POSTGRESQL_USERNAME=owsec -#STORAGE_TYPE_POSTGRESQL_PASSWORD=owsec -#STORAGE_TYPE_POSTGRESQL_DATABASE=owsec -#STORAGE_TYPE_POSTGRESQL_PORT=5432 +STORAGE_TYPE=postgresql +STORAGE_TYPE_POSTGRESQL_HOST=postgresql +STORAGE_TYPE_POSTGRESQL_USERNAME=owsec +STORAGE_TYPE_POSTGRESQL_PASSWORD=owsec +STORAGE_TYPE_POSTGRESQL_DATABASE=owsec +STORAGE_TYPE_POSTGRESQL_PORT=5432 #STORAGE_TYPE_MYSQL_HOST=localhost #STORAGE_TYPE_MYSQL_USERNAME=owsec #STORAGE_TYPE_MYSQL_PASSWORD=owsec #STORAGE_TYPE_MYSQL_DATABASE=owsec #STORAGE_TYPE_MYSQL_PORT=3306 +#STORAGE_TYPE=sqlite diff --git a/docker-compose/owsub.env b/docker-compose/owsub.env index 6d42caf..d349a64 100644 --- a/docker-compose/owsub.env +++ b/docker-compose/owsub.env @@ -26,14 +26,15 @@ SYSTEM_URI_UI=https://openwifi.wlan.local #SECURITY_RESTAPI_DISABLE=false #KAFKA_ENABLE=true KAFKA_BROKERLIST=kafka:9092 -#STORAGE_TYPE=sqlite -#STORAGE_TYPE_POSTGRESQL_HOST=localhost -#STORAGE_TYPE_POSTGRESQL_USERNAME=owsub -#STORAGE_TYPE_POSTGRESQL_PASSWORD=owsub -#STORAGE_TYPE_POSTGRESQL_DATABASE=owsub -#STORAGE_TYPE_POSTGRESQL_PORT=5432 +STORAGE_TYPE=postgresql +STORAGE_TYPE_POSTGRESQL_HOST=postgresql +STORAGE_TYPE_POSTGRESQL_USERNAME=owsub +STORAGE_TYPE_POSTGRESQL_PASSWORD=owsub +STORAGE_TYPE_POSTGRESQL_DATABASE=owsub +STORAGE_TYPE_POSTGRESQL_PORT=5432 #STORAGE_TYPE_MYSQL_HOST=localhost #STORAGE_TYPE_MYSQL_USERNAME=owsub #STORAGE_TYPE_MYSQL_PASSWORD=owsub #STORAGE_TYPE_MYSQL_DATABASE=owsub #STORAGE_TYPE_MYSQL_PORT=3306 +#STORAGE_TYPE=sqlite