From 5456365ec2138488d4dca2029d1893cbffbef659 Mon Sep 17 00:00:00 2001 From: David Randall Date: Sun, 12 Nov 2023 16:10:11 -0500 Subject: [PATCH 1/3] Fix: First time developer setup --- .devcontainer/.env.example | 7 +++++++ .devcontainer/entrypoint.sh | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.devcontainer/.env.example b/.devcontainer/.env.example index a9fa3b37b6..da6aed7903 100644 --- a/.devcontainer/.env.example +++ b/.devcontainer/.env.example @@ -19,6 +19,7 @@ MONGODB_USER=mongouser MONGODB_PASSWORD=mongopass # database settings +POSTGRES_DB=tactical POSTGRES_USER=postgres POSTGRES_PASS=postgrespass @@ -29,3 +30,9 @@ HTTP_PROTOCOL=https DOCKER_NETWORK=172.21.0.0/24 DOCKER_NGINX_IP=172.21.0.20 NATS_PORTS=4222:4222 + +# The nginx container expects CERT_PUB_KEY and CERT_PRIV_KEY to be base64 encoded +CERT_PUB_KEY='VGhlIG5naW54IGNvbnRhaW5lciBleHBlY3RzIENFUlRfUFVCX0tFWSBhbmQgQ0VSVF9QUklWX0tF + WSB0byBiZSBiYXNlNjQgZW5jb2RlZA==' +CERT_PRIV_KEY='VGhlIG5naW54IGNvbnRhaW5lciBleHBlY3RzIENFUlRfUFVCX0tFWSBhbmQgQ0VSVF9QUklWX0tF + WSB0byBiZSBiYXNlNjQgZW5jb2RlZA==' diff --git a/.devcontainer/entrypoint.sh b/.devcontainer/entrypoint.sh index 05c20cace5..89b935441d 100644 --- a/.devcontainer/entrypoint.sh +++ b/.devcontainer/entrypoint.sh @@ -15,6 +15,7 @@ set -e : "${MESH_PASS:=meshcentralpass}" : "${MESH_HOST:=tactical-meshcentral}" : "${API_HOST:=tactical-backend}" +: "${APP_HOST:=tactical-frontend}" : "${REDIS_HOST:=tactical-redis}" : "${API_PORT:=8000}" @@ -49,7 +50,7 @@ function django_setup { MESH_TOKEN="$(cat ${TACTICAL_DIR}/tmp/mesh_token)" DJANGO_SEKRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 80 | head -n 1) - + localvars="$(cat << EOF SECRET_KEY = '${DJANGO_SEKRET}' @@ -69,6 +70,7 @@ ALLOWED_HOSTS = ['${API_HOST}', '*'] ADMIN_URL = 'admin/' CORS_ORIGIN_ALLOW_ALL = True +CORS_ORIGIN_WHITELIST = ['https://${APP_HOST}', 'https://${API_HOST}'] DATABASES = { 'default': { @@ -116,9 +118,9 @@ EOF "${VIRTUAL_ENV}"/bin/python manage.py create_natsapi_conf "${VIRTUAL_ENV}"/bin/python manage.py create_installer_user "${VIRTUAL_ENV}"/bin/python manage.py post_update_tasks - - # create super user + + # create super user echo "from accounts.models import User; User.objects.create_superuser('${TRMM_USER}', 'admin@example.com', '${TRMM_PASS}') if not User.objects.filter(username='${TRMM_USER}').exists() else 0;" | python manage.py shell } From 16294578db735af531f94bcd8a3561a9fe1c1c25 Mon Sep 17 00:00:00 2001 From: David Randall Date: Sun, 12 Nov 2023 16:28:21 -0500 Subject: [PATCH 2/3] Fix: First time developer setup --- .devcontainer/.env.example | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/.env.example b/.devcontainer/.env.example index da6aed7903..6b6846b487 100644 --- a/.devcontainer/.env.example +++ b/.devcontainer/.env.example @@ -32,7 +32,7 @@ DOCKER_NGINX_IP=172.21.0.20 NATS_PORTS=4222:4222 # The nginx container expects CERT_PUB_KEY and CERT_PRIV_KEY to be base64 encoded -CERT_PUB_KEY='VGhlIG5naW54IGNvbnRhaW5lciBleHBlY3RzIENFUlRfUFVCX0tFWSBhbmQgQ0VSVF9QUklWX0tF - WSB0byBiZSBiYXNlNjQgZW5jb2RlZA==' -CERT_PRIV_KEY='VGhlIG5naW54IGNvbnRhaW5lciBleHBlY3RzIENFUlRfUFVCX0tFWSBhbmQgQ0VSVF9QUklWX0tF - WSB0byBiZSBiYXNlNjQgZW5jb2RlZA==' +#CERT_PUB_KEY='VGhlIG5naW54IGNvbnRhaW5lciBleHBlY3RzIENFUlRfUFVCX0tFWSBhbmQgQ0VSVF9QUklWX0tF +# WSB0byBiZSBiYXNlNjQgZW5jb2RlZA==' +#CERT_PRIV_KEY='VGhlIG5naW54IGNvbnRhaW5lciBleHBlY3RzIENFUlRfUFVCX0tFWSBhbmQgQ0VSVF9QUklWX0tF +# WSB0byBiZSBiYXNlNjQgZW5jb2RlZA==' From 2cf1c0d455d2a967ea755bd0296877db1288af02 Mon Sep 17 00:00:00 2001 From: David Randall Date: Mon, 13 Nov 2023 21:10:44 -0500 Subject: [PATCH 3/3] Chg: API_HOST is not needed in CORS_ORIGIN_WHITELIST --- .devcontainer/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/entrypoint.sh b/.devcontainer/entrypoint.sh index 89b935441d..d13519e22a 100644 --- a/.devcontainer/entrypoint.sh +++ b/.devcontainer/entrypoint.sh @@ -70,7 +70,7 @@ ALLOWED_HOSTS = ['${API_HOST}', '*'] ADMIN_URL = 'admin/' CORS_ORIGIN_ALLOW_ALL = True -CORS_ORIGIN_WHITELIST = ['https://${APP_HOST}', 'https://${API_HOST}'] +CORS_ORIGIN_WHITELIST = ['https://${APP_HOST}'] DATABASES = { 'default': {