Skip to content

Commit a6e2d17

Browse files
committed
fix(cli): preserve PGAI_REGISTRY in .env during local-install
- CLI now preserves PGAI_REGISTRY from existing .env file when running local-install (needed for CI with GitLab Container Registry) - Fix CI heredoc indentation that was adding spaces to .env values - Update terraform docs to use docker-compose directly (no Node.js on VM)
1 parent c72dd45 commit a6e2d17

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

.gitlab-ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ cli:node:e2e:dind:
352352
docker images | grep "$CI_REGISTRY_IMAGE"
353353
# Create .env file with registry and tag
354354
- |
355-
cat > .env << EOF
356-
PGAI_REGISTRY=$CI_REGISTRY_IMAGE
357-
PGAI_TAG=$PGAI_TAG
358-
EOF
355+
cat > .env <<EOF
356+
PGAI_REGISTRY=$CI_REGISTRY_IMAGE
357+
PGAI_TAG=$PGAI_TAG
358+
EOF
359359
script:
360360
- ./tests/e2e.cli.sh
361361
after_script:
@@ -396,10 +396,10 @@ cli:node:full:dind:
396396
docker images | grep "$CI_REGISTRY_IMAGE"
397397
# Create .env file with registry and tag
398398
- |
399-
cat > .env << EOF
400-
PGAI_REGISTRY=$CI_REGISTRY_IMAGE
401-
PGAI_TAG=$PGAI_TAG
402-
EOF
399+
cat > .env <<EOF
400+
PGAI_REGISTRY=$CI_REGISTRY_IMAGE
401+
PGAI_TAG=$PGAI_TAG
402+
EOF
403403
script:
404404
- echo "=== Testing local-install (demo mode) ==="
405405
- node ./cli/dist/bin/postgres-ai.js mon local-install --demo

cli/bin/postgres-ai.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,11 +1187,16 @@ mon
11871187
const envFile = path.resolve(projectDir, ".env");
11881188
const imageTag = opts.tag || pkg.version;
11891189

1190-
// Build .env content
1190+
// Build .env content, preserving important existing values
11911191
const envLines: string[] = [`PGAI_TAG=${imageTag}`];
1192-
// Preserve GF_SECURITY_ADMIN_PASSWORD if it exists
11931192
if (fs.existsSync(envFile)) {
11941193
const existingEnv = fs.readFileSync(envFile, "utf8");
1194+
// Preserve PGAI_REGISTRY if it exists (for CI/custom registry usage)
1195+
const registryMatch = existingEnv.match(/^PGAI_REGISTRY=(.+)$/m);
1196+
if (registryMatch) {
1197+
envLines.push(`PGAI_REGISTRY=${registryMatch[1].trim()}`);
1198+
}
1199+
// Preserve GF_SECURITY_ADMIN_PASSWORD if it exists
11951200
const pwdMatch = existingEnv.match(/^GF_SECURITY_ADMIN_PASSWORD=(.+)$/m);
11961201
if (pwdMatch) {
11971202
envLines.push(`GF_SECURITY_ADMIN_PASSWORD=${pwdMatch[1]}`);

terraform/aws/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ Method 2: Manual configuration (avoids credentials in state):
179179
ssh ubuntu@your-ip
180180
cd /home/postgres_ai/postgres_ai
181181
sudo -u postgres_ai vim instances.yml
182-
sudo -u postgres_ai postgresai mon update-config
182+
sudo -u postgres_ai docker-compose run --rm sources-generator
183+
sudo -u postgres_ai docker-compose restart pgwatch-postgres pgwatch-prometheus
183184
```
184185

185186
### Backup

0 commit comments

Comments
 (0)