From d941b52ebec99e47ec2e66469ef2ccfe46a87afe Mon Sep 17 00:00:00 2001 From: Bryan Enders <2033828+bryanenders@users.noreply.github.com> Date: Mon, 14 Nov 2022 09:14:27 -0500 Subject: [PATCH 1/6] Make script SIGINT cleaner (#15) --- bin/down | 4 +--- bin/init | 26 +++++++++++--------------- bin/observe | 1 - bin/reset | 7 +++---- bin/up | 4 +--- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/bin/down b/bin/down index 9664df5..6665839 100755 --- a/bin/down +++ b/bin/down @@ -1,5 +1,3 @@ #!/bin/bash -hash mutagen-compose || exit 1 - -basedir=$(readlink -f "$(dirname "$0")/..") +basedir=$(dirname "$0")/.. mutagen-compose -f "$basedir/docker-compose.yml" down diff --git a/bin/init b/bin/init index d639c5c..d3bec4d 100755 --- a/bin/init +++ b/bin/init @@ -1,7 +1,5 @@ #!/bin/bash -hash git || exit 1 hash mutagen-compose || exit 1 -trap 'exit 1' INT QUIT basedir=$(readlink -f "$(dirname "$0")/..") servicesdir=$basedir/services @@ -15,19 +13,17 @@ git clone https://github.com/mozilla/dialog.git "$servicesdir/dialog" git clone https://github.com/mozilla/hubs.git "$servicesdir/hubs" git clone https://github.com/mozilla/Spoke.git "$servicesdir/spoke" -echo -e "\n${bright}Initializing Reticulum${reset}\n" -mutagen-compose -f "$composefile" run --rm reticulum sh -c 'mix do deps.get, deps.compile, ecto.create' - -echo -e "\n${bright}Initializing Dialog${reset}\n" -mutagen-compose -f "$composefile" run --rm dialog sh -c '[ -d "node_modules" ] || npm ci' - -echo -e "\n${bright}Initializing Hubs Admin${reset}\n" -mutagen-compose -f "$composefile" run --rm hubs-admin sh -c '[ -d "node_modules" ] || npm ci' - -echo -e "\n${bright}Initializing Hubs Client${reset}\n" -mutagen-compose -f "$composefile" run --rm hubs-client sh -c '[ -d "node_modules" ] || npm ci' - -echo -e "\n${bright}Initializing Spoke${reset}\n" +echo -e "\n${bright}Initializing Reticulum${reset}\n" && +mutagen-compose -f "$composefile" run --rm reticulum sh -c 'mix do deps.get, deps.compile, ecto.create' && +echo -e "\n${bright}Initializing Dialog${reset}\n" && +mutagen-compose -f "$composefile" run --rm dialog sh -c '[ -d "node_modules" ] || npm ci' && +echo -e "\n${bright}Initializing Hubs Admin${reset}\n" && +mutagen-compose -f "$composefile" run --rm hubs-admin sh -c '[ -d "node_modules" ] || npm ci' && +echo -e "\n${bright}Initializing Hubs Client${reset}\n" && +mutagen-compose -f "$composefile" run --rm hubs-client sh -c '[ -d "node_modules" ] || npm ci' && +echo -e "\n${bright}Initializing Spoke${reset}\n" && mutagen-compose -f "$composefile" run --rm spoke yarn +code=$? mutagen-compose down +exit $code diff --git a/bin/observe b/bin/observe index fc31257..65a89d6 100755 --- a/bin/observe +++ b/bin/observe @@ -1,6 +1,5 @@ #!/bin/bash hash docker-compose || exit 1 -hash tmux || exit 1 hash watch || exit 1 basedir=$(readlink -f "$(dirname "$0")/..") diff --git a/bin/reset b/bin/reset index 9640ddb..4a27e24 100755 --- a/bin/reset +++ b/bin/reset @@ -1,7 +1,6 @@ #!/bin/bash -hash mutagen-compose || exit 1 - basedir=$(readlink -f "$(dirname "$0")/..") -mutagen-compose -f "$basedir/docker-compose.yml" down --volumes --rmi local -rm -r "$basedir/services/reticulum/deps" + +mutagen-compose -f "$basedir/docker-compose.yml" down --volumes --rmi local && +rm -rf "$basedir/services/reticulum/deps" && "$basedir/bin/init" diff --git a/bin/up b/bin/up index b01055d..3585adf 100755 --- a/bin/up +++ b/bin/up @@ -1,5 +1,3 @@ #!/bin/bash -hash mutagen-compose || exit 1 - -basedir=$(readlink -f "$(dirname "$0")/..") +basedir=$(dirname "$0")/.. mutagen-compose -f "$basedir/docker-compose.yml" up --build --detach From 7a80b1f8a7086e65cdd8ef6622df161fa52846ab Mon Sep 17 00:00:00 2001 From: Bryan Enders <2033828+bryanenders@users.noreply.github.com> Date: Tue, 15 Nov 2022 08:10:07 -0500 Subject: [PATCH 2/6] Add health check to hubs-storybook --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 7b553f9..6859ed0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,6 +62,8 @@ services: dockerfile: dockerfiles/hubs.Dockerfile target: dev command: npm run storybook + healthcheck: + test: ["CMD", "curl", "-fk", "http://hubs.local:6006"] ports: - "6006:6006" volumes: From 9c233cc2e3d180f52e7dad78e7a4b95f4fc7118c Mon Sep 17 00:00:00 2001 From: Bryan Enders <2033828+bryanenders@users.noreply.github.com> Date: Wed, 16 Nov 2022 09:13:53 -0500 Subject: [PATCH 3/6] Add proxy instructions to README --- README.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2e59f57..eceb6f9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ Hubs Compose is a Docker Compose setup than can be used to orchestrate all the services used by Mozilla Hubs for local development.[^1] [^1]: This is not a production-ready setup. It does not account for -security or scalability. Additionally the permissions files were generated for development purposes only. +security or scalability. Additionally the permissions files were generated for +development purposes only. ## Usage @@ -34,21 +35,22 @@ certificates, you can visit https://hubs.local:4000 from your browser. ### Self-Signed Certificates Service communication is encrypted with self-signed Transport Layer Security -(TLS) certificates. You will need to accept the certificate at each of the -ports mapped in [`docker-compose.yml`](docker-compose.yml). At the time of this -writing, that means visiting these links in your web browser and following the -prompts: - -* [4443: Dialog](https://hubs.local:4443) -* [9090: Spoke](https://hubs.local:9090) -* [8989: Hubs Admin](https://hubs.local:8989) -* [8080: Hubs Client](https://hubs.local:8080) -* [4000: Reticulum](https://hubs.local:4000) +(TLS) certificates. You will need to accept the proxy certificate and the +certificate at each of the Hubs ports mapped in +[`docker-compose.yml`](docker-compose.yml). At the time of this writing, that +means visiting these links in your web browser and following the prompts: + +* [Proxy](https://hubs-proxy.local:4000) +* [Dialog](https://hubs.local:4443) +* [Spoke](https://hubs.local:9090) +* [Hubs Admin](https://hubs.local:8989) +* [Hubs Client](https://hubs.local:8080) +* [Reticulum](https://hubs.local:4000) ### Admin panel access -To connect to the admin panel you will need to manually promote an account to admin: -https://github.com/mozilla/reticulum#6-creating-an-admin-user +To connect to the admin panel you will need to manually +[promote an account to admin](https://github.com/mozilla/reticulum#6-creating-an-admin-user). ### Command Execution From 76072b4a43ab0c7322db9e871376098db65ad754 Mon Sep 17 00:00:00 2001 From: Bryan Enders <2033828+bryanenders@users.noreply.github.com> Date: Wed, 16 Nov 2022 10:39:35 -0500 Subject: [PATCH 4/6] Fix Spoke Why --- When loading assets Spoke emits this error: > Error loading glTF root: Cause: Network Error: Unknown Status. Unknown > Error. Possibly a CORS error. This is because Spoke uses https://hubs-proxy.com as a CORS proxy. What ---- Configure Spoke to use local CORS proxy --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 6859ed0..8967658 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -104,6 +104,7 @@ services: target: dev command: ./scripts/run-local-reticulum.sh environment: + CORS_PROXY_SERVER: "hubs-proxy.local:4000" INTERNAL_HOSTNAME: spoke ports: - "9090:9090" From c0f4df9b8fb31eff005a2b95682fc6aae1f369d5 Mon Sep 17 00:00:00 2001 From: Bryan Enders <2033828+bryanenders@users.noreply.github.com> Date: Wed, 16 Nov 2022 13:18:00 -0500 Subject: [PATCH 5/6] Update Reticulum health check --- dockerfiles/reticulum.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/reticulum.Dockerfile b/dockerfiles/reticulum.Dockerfile index f9adeb5..bf07eea 100644 --- a/dockerfiles/reticulum.Dockerfile +++ b/dockerfiles/reticulum.Dockerfile @@ -4,7 +4,7 @@ ARG ELIXIR_VERSION=1.8.2 ARG OTP_VERSION=22.3.4 FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-alpine-${ALPINE_LINUX_VERSION} AS dev -HEALTHCHECK CMD wget --no-check-certificate https://localhost:4000/link -O /dev/null || exit 1 +HEALTHCHECK CMD wget --no-check-certificate --no-verbose --tries=1 --spider https://localhost:4000/stream-offline.png RUN mix do local.hex --force, local.rebar --force RUN apk add --no-cache\ # required by hex\ From 668e39b44bd11652831dcd8930510c4a026959cb Mon Sep 17 00:00:00 2001 From: Bryan Enders <2033828+bryanenders@users.noreply.github.com> Date: Wed, 16 Nov 2022 15:02:08 -0500 Subject: [PATCH 6/6] Run db service under postgres instead of root --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8967658..ab70c2f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,10 +3,10 @@ services: db: environment: POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres healthcheck: test: ["CMD", "pg_isready"] image: "postgres:14-alpine" + user: postgres volumes: - pgdata:/var/lib/postgresql/data dialog: