Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(local): fix fusion auth env on worktrees (#3048)

teoab6b7bc881a0
diff --git a/docker-compose-databases.yml b/docker-compose-databases.yml
index ef30d24a60..09bf1bf8b9 100644
--- a/docker-compose-databases.yml
+++ b/docker-compose-databases.yml
@@ -69,10 +69,10 @@ networks:
volumes:
db:
name: macro_postgres_data
- driver: local
+ external: true
cache:
name: macro_redis_data
- driver: local
+ external: true
opensearch_data:
name: macro_opensearch_data
- driver: local
+ external: true
diff --git a/infra/stacks/fusionauth-instance/docker-compose.yml b/infra/stacks/fusionauth-instance/docker-compose.yml
index f31979228e..6aa70f1589 100644
--- a/infra/stacks/fusionauth-instance/docker-compose.yml
+++ b/infra/stacks/fusionauth-instance/docker-compose.yml
@@ -6,10 +6,13 @@ name: macro
services:
db:
image: postgres:16.0-bookworm
+ env_file:
+ - path: .env
+ required: false
environment:
PGDATA: /var/lib/postgresql/data/pgdata
- POSTGRES_USER: ${POSTGRES_USER}
- POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
+ POSTGRES_USER: ${POSTGRES_USER:-postgres}
+ POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
@@ -22,6 +25,9 @@ services:
fusionauth:
image: fusionauth/fusionauth-app:1.62.1
+ env_file:
+ - path: .env
+ required: false
depends_on:
db:
condition: service_healthy
@@ -29,16 +35,15 @@ services:
# condition: service_healthy
environment:
DATABASE_URL: jdbc:postgresql://db:5432/fusionauth
- DATABASE_ROOT_USERNAME: ${POSTGRES_USER}
- DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD}
- DATABASE_USERNAME: ${DATABASE_USER}
- DATABASE_PASSWORD: ${DATABASE_PASSWORD}
+ DATABASE_ROOT_USERNAME: ${POSTGRES_USER:-postgres}
+ DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
+ DATABASE_USERNAME: ${DATABASE_USER:-fusionauth}
FUSIONAUTH_APP_KICKSTART_FILE: /usr/local/fusionauth/kickstart/kickstart.json
FUSIONAUTH_APP_MEMORY: 512M
FUSIONAUTH_APP_RUNTIME_MODE: development
FUSIONAUTH_APP_URL: http://fusionauth:9011
healthcheck:
- test: curl --silent --fail http://localhost:9011/api/status -o /dev/null -w "%{http_code}"
+ test: ["CMD-SHELL", "curl -s http://localhost:9011/api/status | grep -q '\"status\":\"Ok\"'"]
interval: 5s
timeout: 5s
retries: 5
@@ -54,8 +59,10 @@ services:
volumes:
db_data:
name: fusionauth_db_data
+ external: true
fusionauth_config:
name: fusionauth_config
+ external: true
networks:
auth-internal:
diff --git a/infra/stacks/fusionauth-instance/justfile b/infra/stacks/fusionauth-instance/justfile
index 5dd5520cf0..ce31fa660c 100644
--- a/infra/stacks/fusionauth-instance/justfile
+++ b/infra/stacks/fusionauth-instance/justfile
@@ -10,6 +10,10 @@ get_fusionauth_env:
# Starts up the local FusionAuth instance. This should only be used during setup/testing.
start *ARGS:
@echo "Starting fusionauth"
+ test -f .env || just get_fusionauth_env
+ docker network create auth 2>/dev/null || true
+ docker volume create fusionauth_db_data >/dev/null
+ docker volume create fusionauth_config >/dev/null
docker-compose up {{ ARGS }}
# Stops the local FusionAuth instance. This should only be used for setup/testing.
diff --git a/justfile b/justfile
index c968c9593f..df94262d8e 100644
--- a/justfile
+++ b/justfile
@@ -8,7 +8,12 @@ export COMPOSE_PROJECT_NAME := "macro"
create_networks:
docker network create databases 2>/dev/null || true -- db network
docker network create auth 2>/dev/null || true -- fusionauth network
- echo "docker networks created"
+ docker volume create macro_postgres_data >/dev/null
+ docker volume create macro_redis_data >/dev/null
+ docker volume create macro_opensearch_data >/dev/null
+ docker volume create fusionauth_db_data >/dev/null
+ docker volume create fusionauth_config >/dev/null
+ echo "docker networks and volumes created"
fix_environment *ARGS:
# Decrypt ignoring mac error
@@ -120,18 +125,26 @@ patch_local_fusionauth_env:
echo " Run 'just setup' if this is a fresh checkout."
exit 0
fi
+ if [ ! -f infra/stacks/fusionauth-instance/.env ]; then
+ echo "FusionAuth docker env not found; downloading it..."
+ just infra/stacks/fusionauth-instance/get_fusionauth_env
+ fi
# FusionAuth must be running to read the client secret
NEEDS_STOP=false
+ cleanup() {
+ if [ "$NEEDS_STOP" = true ]; then
+ echo "Stopping temporary FusionAuth..."
+ docker compose stop fusionauth
+ fi
+ }
+ trap cleanup EXIT
+
if ! curl -s http://localhost:9011/api/status 2>/dev/null | grep -q '"Ok"'; then
echo "Starting FusionAuth temporarily to read config..."
- docker compose up fusionauth -d --wait
NEEDS_STOP=true
+ docker compose up fusionauth -d --wait
fi
just infra/stacks/fusionauth-instance/insert_local_fusionauth_variables
- if [ "$NEEDS_STOP" = true ]; then
- echo "Stopping temporary FusionAuth..."
- docker compose stop fusionauth
- fi
# Stop all local services
stop-local: