-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdocker-local.sh
More file actions
executable file
·91 lines (71 loc) · 3.41 KB
/
Copy pathdocker-local.sh
File metadata and controls
executable file
·91 lines (71 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Local Docker Build and Deploy Script
# This script builds all Nx apps, Docker images, and starts a local production-like stack
# Ports are offset by +10 to avoid conflicts with other docker-compose stacks
set -e # Exit on any error
COMPOSE_FILE="dockerfile/local/docker-compose.yaml"
# An explicit `-f` disables Compose's auto-detection of override files, so include
# the override ourselves when it exists (installed at runtime by
# scripts/install-michel-skills.sh for the sprite sandbox). No-op for normal local
# dev where the override is absent.
COMPOSE_OVERRIDE="dockerfile/local/docker-compose.override.yaml"
COMPOSE_ARGS=(-f "$COMPOSE_FILE")
if [ -f "$COMPOSE_OVERRIDE" ]; then
COMPOSE_ARGS+=(-f "$COMPOSE_OVERRIDE")
echo "ℹ️ Using compose override: $COMPOSE_OVERRIDE"
fi
# ========================================================================
# STEP 1: BUILD NX APPS
# ========================================================================
echo "🔨 Building Nx applications..."
# Generate tsconfig
echo "📝 Generating tsconfig..."
PACKMIND_EDITION=${PACKMIND_EDITION:-oss} node scripts/select-tsconfig.mjs
# Build all apps
echo "📦 Building frontend..."
./node_modules/.bin/nx build frontend --configuration=production
echo "📦 Building API..."
./node_modules/.bin/nx build api --configuration=production
# Bundle migrations for Docker
echo "📦 Bundling migrations for Docker..."
./node_modules/.bin/nx bundle-docker migrations
echo "✅ All Nx builds completed!"
# ========================================================================
# STEP 2: BUILD DOCKER IMAGES
# ========================================================================
# Dockerfile.api copies dist/packages/standards/samples/generated into the image.
# In CI that directory comes from a "Download standard samples artifacts" step in
# the docker job; locally it has to be built. Neither app build produces it — both
# bundle the packages from source — and the Dockerfile guards the copy with
# `if [ -d ... ]`, so without this the image silently ships without samples.
echo "📦 Preparing image inputs: standard samples..."
./node_modules/.bin/nx build standards
echo "🐳 Building Docker images..."
# Build API image
echo "📦 Building API Docker image..."
docker build -f dockerfile/Dockerfile.api -t packmind-api-local .
# Build Frontend image
echo "📦 Building Frontend Docker image..."
docker build -f dockerfile/Dockerfile.frontend -t packmind-frontend-local .
echo "✅ All Docker images built successfully!"
# ========================================================================
# STEP 3: START LOCAL STACK
# ========================================================================
# Stop any existing local containers
echo "🛑 Stopping existing local containers..."
docker compose "${COMPOSE_ARGS[@]}" down || true
# Start the local stack
echo "🚀 Starting local stack..."
docker compose "${COMPOSE_ARGS[@]}" up -d
echo "🎉 Local stack is running!"
echo ""
echo "📍 Service URLs:"
echo " Frontend: http://localhost:8091"
echo " API: http://localhost:8091/api"
echo " API direct: http://localhost:3010"
echo " PostgreSQL: localhost:5442"
echo " Redis: localhost:6389"
echo ""
echo "📊 Check status with: docker compose -f $COMPOSE_FILE ps"
echo "📜 View logs with: docker compose -f $COMPOSE_FILE logs -f"
echo "🛑 Stop with: docker compose -f $COMPOSE_FILE down"