diff --git a/.docker-compose.http.yml b/.docker-compose.http.yml index d49e0d1..eaa9225 100644 --- a/.docker-compose.http.yml +++ b/.docker-compose.http.yml @@ -22,16 +22,10 @@ services: db-odc: condition: service_healthy restart: unless-stopped - - environment: - DATABASE_URL: mysql://odc:@db-odc:3306/odc - OAUTH_KEYCLOAK_CLIENT_ID: opendatenschutzcenter - OAUTH_KEYCLOAK_CLIENT_SECRET: - OAUTH_KEYCLOAK_SERVER: ':///keycloak' - OAUTH_KEYCLOAK_REALM: opendatenschutzcenter - MAILER_DSN: 'null://null' - laF_version: 3.0.4 - demo_installation: demo + env_file: + - ./.env + - ./.env.local + - ./.env.custom labels: - "traefik.enable=true" - "traefik.http.routers.app-odc.rule=Host(``)" @@ -62,18 +56,10 @@ services: depends_on: db-odc: condition: service_healthy - environment: - KEYCLOAK_ADMIN: admin - KEYCLOAK_ADMIN_PASSWORD: - KC_DB: mariadb - KC_DB_PASSWORD: - KC_DB_URL: jdbc:mariadb://db-odc:3306/keycloak - KC_DB_USERNAME: keycloak - KC_HOSTNAME_URL: :///keycloak - KC_HOSTNAME_PATH: :///keycloak - KC_HOSTNAME_ADMIN_URL: :///keycloak - KC_HTTP_RELATIVE_PATH: /keycloak - KC_PROXY: passthrough + env_file: + - ./.env + - ./.env.local + - ./.env.custom command: - start-dev - --import-realm diff --git a/setup.sh b/setup.sh index 32d6ab1..607d78a 100644 --- a/setup.sh +++ b/setup.sh @@ -38,11 +38,11 @@ else KEYCLOAK_PW=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) ODC_DB_PW=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) KEYCLOAK_ADMIN_PW=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) - OAUTH_KEYCLOAK_CLIENT_ID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) + NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) echo "KEYCLOAK_PW=$KEYCLOAK_PW" >> $FILE echo "KEYCLOAK_ADMIN_PW=$KEYCLOAK_ADMIN_PW" >> $FILE - echo "OAUTH_KEYCLOAK_CLIENT_ID=$OAUTH_KEYCLOAK_CLIENT_ID" >> $FILE + echo "NEW_UUID=$NEW_UUID" >> $FILE echo "ODC_DB_PW=$ODC_DB_PW" >> $FILE source $FILE fi @@ -68,7 +68,7 @@ echo ------------------------------------------------------------ echo "" cp keycloak/.realm-export.json keycloak/realm-export.json -sed -i "s||$OAUTH_KEYCLOAK_CLIENT_ID|g" keycloak/realm-export.json +sed -i "s||$NEW_UUID|g" keycloak/realm-export.json sed -i "s||$HTTP_METHOD://$PUBLIC_URL|g" keycloak/realm-export.json echo ------------------------------------------------------------ @@ -80,21 +80,54 @@ cp mysql-initdb/.init-userdb.sql mysql-initdb/init-userdb.sql sed -i "s||$ODC_DB_PW|g" mysql-initdb/init-userdb.sql sed -i "s||$KEYCLOAK_PW|g" mysql-initdb/init-userdb.sql + echo ------------------------------------------------------------ -echo --------- 3. Build Docker Compose File --------------------- +echo --------- 3. Setup .ENV.LOCAL ------------------------------ +echo ------------------------------------------------------------ +echo "" + +if [ -f .env.local ]; then + rm .env.local +fi + +cat < .env.local +# ENV FOR ODC +PUBLIC_URL='$PUBLIC_URL' +MAILER_DSN='null://null' +DATABASE_URL='mysql://odc:$JITSI_ADMIN_PW@db-odc:3306/odc' +OAUTH_KEYCLOAK_CLIENT_SECRET=$NEW_UUID +OAUTH_KEYCLOAK_SERVER='$HTTP_METHOD://$PUBLIC_URL/keycloak' +OAUTH_KEYCLOAK_CLIENT_ID=opendatenschutzcenter +OAUTH_KEYCLOAK_REALM=opendatenschutzcenter +laF_version: 3.0.4 +demo_installation: demo + +# ENV FOR KEYCLOAK +KEYCLOAK_ADMIN=admin +KEYCLOAK_ADMIN_PASSWORD=$KEYCLOAK_ADMIN_PW +KC_DB=mariadb +KC_DB_USERNAME=keycloak +KC_DB_PASSWORD=$KEYCLOAK_PW +KC_DB_URL='jdbc:mariadb://db-odc:3306/keycloak' +KC_HOSTNAME_URL='$HTTP_METHOD://$PUBLIC_URL/keycloak' +KC_HOSTNAME_PATH='$HTTP_METHOD://$PUBLIC_URL/keycloak' +KC_HOSTNAME_ADMIN_URL='$HTTP_METHOD://$PUBLIC_URL/keycloak' +KC_HTTP_RELATIVE_PATH=/keycloak +KC_PROXY=passthrough +EOL + + +echo ------------------------------------------------------------ +echo ------------ 4. Build Docker Compose File ------------------ echo ------------------------------------------------------------ echo "" cp .docker-compose.$HTTP_METHOD.yml docker-compose.yml -sed -i "s||$KEYCLOAK_ADMIN_PW|g" docker-compose.yml -sed -i "s||$KEYCLOAK_PW|g" docker-compose.yml -sed -i "s||$OAUTH_KEYCLOAK_CLIENT_ID|g" docker-compose.yml sed -i "s||$PUBLIC_URL|g" docker-compose.yml -sed -i "s||$HTTP_METHOD|g" docker-compose.yml -sed -i "s||$ODC_DB_PW|g" docker-compose.yml sed -i "s||$HOST_IP|g" docker-compose.yml + echo "" echo "" echo ------------------------------------------------------------