feat: enhance service discovery and proxy management
This commit is contained in:
@@ -17,6 +17,22 @@ compose() {
|
||||
docker compose --env-file "$ENV_FILE" -f "$ROOT_DIR/docker-compose.yml" "$@"
|
||||
}
|
||||
|
||||
playground() {
|
||||
docker compose -f "$ROOT_DIR/playground/docker-compose.yml" "$@"
|
||||
}
|
||||
|
||||
sync_env_values() {
|
||||
local mongo_pass mongo_db
|
||||
mongo_pass=$(grep -E '^MONGO_INITDB_ROOT_PASSWORD=' "$ENV_FILE" | cut -d '=' -f2-)
|
||||
mongo_db=$(grep -E '^MONGODB_DB_NAME=' "$ENV_FILE" | cut -d '=' -f2-)
|
||||
|
||||
[[ -n "$mongo_db" ]] || mongo_db="theplug"
|
||||
|
||||
if [[ -n "$mongo_pass" ]]; then
|
||||
sed -i "s|^MONGODB_URI=.*|MONGODB_URI=mongodb://theplug:$mongo_pass@localhost:27017/$mongo_db?authSource=admin|" "$ENV_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_env() {
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
return
|
||||
@@ -64,12 +80,29 @@ EOF
|
||||
|
||||
start_stack() {
|
||||
ensure_env
|
||||
sync_env_values
|
||||
info "Building and starting backend, frontend, MongoDB and Redis..."
|
||||
compose up -d --build
|
||||
info "Backend: http://localhost:$(grep -E '^API_PORT=' "$ENV_FILE" | cut -d '=' -f2 || echo 3671)"
|
||||
info "Frontend: http://localhost:$(grep -E '^FRONTEND_PORT=' "$ENV_FILE" | cut -d '=' -f2 || echo 5173)"
|
||||
}
|
||||
|
||||
start_deps() {
|
||||
ensure_env
|
||||
sync_env_values
|
||||
info "Starting MongoDB and Redis for host-backend testing..."
|
||||
compose up -d mongodb redis
|
||||
info "Now run these on the host:"
|
||||
info " npm run dev:backend"
|
||||
info " npm run dev:frontend"
|
||||
}
|
||||
|
||||
start_playground() {
|
||||
info "Starting local playground upstream service..."
|
||||
playground up -d
|
||||
info "Playground service: http://127.0.0.1:9081"
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "service" ]]; then
|
||||
ensure_env
|
||||
install_service
|
||||
@@ -77,6 +110,16 @@ if [[ "${1:-}" == "service" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "${1:-}" == "deps" ]]; then
|
||||
start_deps
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "${1:-}" == "playground" ]]; then
|
||||
start_playground
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -d "/srv/theplug" && "$ROOT_DIR" != "/srv/theplug" ]]; then
|
||||
info "thePlug found in /srv/theplug, switching there"
|
||||
cd /srv/theplug
|
||||
|
||||
Reference in New Issue
Block a user