-
Notifications
You must be signed in to change notification settings - Fork 8
170 lines (134 loc) · 5.33 KB
/
Copy pathdagster-oss-deploy.yml
File metadata and controls
170 lines (134 loc) · 5.33 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Deploy to Dagster OSS on GCP
'on':
push:
branches:
- main
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'production'
type: choice
options:
- production
- staging
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_ZONE: ${{ secrets.GCP_ZONE }}
VM_NAME: ${{ secrets.GCP_VM_NAME }}
jobs:
deploy:
if: false # Temporarily disabled - remove this line when ready to deploy
name: Deploy Dagster OSS
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 1
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@c200f3691d83b41bf9bbd8638997a462592937ed # v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@e427ad8a34f8676edf47cf7d7925499adf3eb74f # v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Prepare deployment files
run: |
echo "Preparing deployment package..."
mkdir -p deploy_temp
# Copy Docker and Dagster configuration files
cp docker-compose.yml deploy_temp/
cp dagster.yaml deploy_temp/
cp workspace.yaml deploy_temp/
# Copy macro_agents code
cp -r macro_agents deploy_temp/
# Copy dbt_project (needed for dbt assets)
cp -r dbt_project deploy_temp/
echo "Deployment package prepared"
- name: Copy files to GCP VM
run: |
echo "Copying files to VM: $VM_NAME in zone $GCP_ZONE..."
# Create dagster directory on VM if it doesn't exist
gcloud compute ssh $VM_NAME --zone=$GCP_ZONE --command='mkdir -p ~/dagster'
# Copy all files
gcloud compute scp --recurse deploy_temp/* $VM_NAME:~/dagster/ --zone=$GCP_ZONE
echo "Files copied successfully"
- name: Deploy on GCP VM
run: |
echo "Deploying Dagster OSS on VM..."
gcloud compute ssh $VM_NAME --zone=$GCP_ZONE --command='
cd ~/dagster
# Pull latest base images
docker compose pull dagster_webserver dagster_daemon
# Stop existing containers
docker compose down
# Build user code image
docker compose build dagster_user_code
# Start all services
docker compose up -d
# Wait for services to start
sleep 15
# Check container status
echo "Container status:"
docker compose ps
# Check for any failed containers
if docker compose ps | grep -q "Exit"; then
echo "ERROR: Some containers failed to start"
docker compose logs
exit 1
fi
'
echo "Deployment completed"
- name: Health check
# Probe the Dagster webserver from inside the VM via SSH rather than
# hitting an external IP over plain HTTP. The Terraform firewall
# rejects external traffic on port 3000 (access is via IAP), so the
# old external-IP curl was both insecure and bypassed that intent.
run: |
echo "Performing health check via SSH..."
MAX_RETRIES=10
RETRY_COUNT=0
sleep 30
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
if gcloud compute ssh "$VM_NAME" --zone="$GCP_ZONE" --command='curl -f -s -o /dev/null http://localhost:3000'; then
echo "Dagster UI is healthy (responding on localhost:3000 inside VM)"
exit 0
fi
echo "Attempt $((RETRY_COUNT + 1))/$MAX_RETRIES: Dagster UI not ready yet..."
RETRY_COUNT=$((RETRY_COUNT + 1))
sleep 10
done
echo "Health check failed - Dagster UI not accessible after $MAX_RETRIES attempts"
gcloud compute ssh "$VM_NAME" --zone="$GCP_ZONE" --command='docker compose logs --tail=100'
exit 1
- name: Verify deployment
run: |
echo "Verifying Dagster services..."
gcloud compute ssh $VM_NAME --zone=$GCP_ZONE --command='
cd ~/dagster
echo "=== Container Health ==="
docker compose ps
echo ""
echo "=== PostgreSQL Status ==="
docker compose exec -T dagster_postgresql pg_isready -U dagster_user || echo "PostgreSQL not ready"
echo ""
echo "=== Recent Webserver Logs ==="
docker compose logs --tail=20 dagster_webserver
echo ""
echo "=== Recent Daemon Logs ==="
docker compose logs --tail=20 dagster_daemon
'
- name: Notify on failure
if: failure()
run: |
echo "Deployment failed! Check the logs above for details."
echo "SSH command: gcloud compute ssh $VM_NAME --zone=$GCP_ZONE"
- name: Notify on success
if: success()
run: |
echo "Deployment successful."
echo "Dagster UI is exposed via IAP (not direct external IP)."
echo "To view logs: gcloud compute ssh $VM_NAME --zone=$GCP_ZONE --command='cd ~/dagster && docker compose logs -f'"