Skip to content

Commit 6202803

Browse files
committed
Merge branch 'fix/publish-pgwatch-image' into 'main'
fix(ci): publish postgresai/pgwatch image Closes #179 See merge request postgres-ai/postgresai!255
2 parents f021c1a + fab8bce commit 6202803

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

.gitlab-ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,20 @@ build:test:images:
158158
monitoring_flask_backend
159159
docker push "$CI_REGISTRY_IMAGE/monitoring-flask-backend:$PGAI_TAG"
160160
161+
# Build and push pgwatch (forked from cybertec-postgresql/pgwatch v3.7.0
162+
# with extension-version-0.0 patch — see pgwatch/Dockerfile)
163+
docker build \
164+
-f pgwatch/Dockerfile \
165+
-t "$CI_REGISTRY_IMAGE/pgwatch:$PGAI_TAG" \
166+
pgwatch
167+
docker push "$CI_REGISTRY_IMAGE/pgwatch:$PGAI_TAG"
168+
161169
echo ""
162170
echo "Images pushed to GitLab Container Registry:"
163171
echo " $CI_REGISTRY_IMAGE/postgres-ai-configs:$PGAI_TAG"
164172
echo " $CI_REGISTRY_IMAGE/reporter:$PGAI_TAG"
165173
echo " $CI_REGISTRY_IMAGE/monitoring-flask-backend:$PGAI_TAG"
174+
echo " $CI_REGISTRY_IMAGE/pgwatch:$PGAI_TAG"
166175
rules:
167176
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
168177
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH =~ /^feature\//'
@@ -572,11 +581,19 @@ cli:npm:publish:
572581
--push \
573582
config
574583

584+
docker buildx build \
585+
--platform "$PLATFORMS" \
586+
-f pgwatch/Dockerfile \
587+
-t "postgresai/pgwatch:$VERSION" \
588+
--push \
589+
pgwatch
590+
575591
echo ""
576592
echo "Published images:"
577593
echo " postgresai/reporter:$VERSION"
578594
echo " postgresai/monitoring-flask-backend:$VERSION"
579595
echo " postgresai/postgres-ai-configs:$VERSION"
596+
echo " postgresai/pgwatch:$VERSION"
580597

581598
docker:publish:images:
582599
<<: *docker-publish-base

pgwatch/Dockerfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
# Based on: cybertec-postgresql/pgwatch v3.7.0
1212

1313
# ---- Stage 1: build WebUI ----
14-
FROM node:22 AS uibuilder
14+
# Pin to BUILDPLATFORM so the WebUI build (yarn install + react-scripts build)
15+
# runs on the runner's native arch. The output is static JS/CSS/HTML — fully
16+
# arch-independent — so a single build serves both linux/amd64 and linux/arm64
17+
# final images. Without this, `docker buildx --platform linux/amd64,linux/arm64`
18+
# would run the WebUI build under QEMU emulation for arm64, taking 30+ min and
19+
# overrunning the GitLab runner's 1h job timeout.
20+
FROM --platform=$BUILDPLATFORM node:22 AS uibuilder
1521

1622
# Pin to the exact commit SHA of the v3.7.0 tag in upstream. Tags are
1723
# mutable (force-push etc.), so we verify the checkout resolves to this SHA
@@ -28,7 +34,13 @@ RUN git clone --depth 1 --branch "${PGWATCH_VERSION}" \
2834
RUN cd /src/internal/webui && yarn install --network-timeout 100000 && yarn build
2935

3036
# ---- Stage 2: patch & build Go binary ----
31-
FROM golang:1.24 AS builder
37+
# Pin to BUILDPLATFORM and use Go's native cross-compilation via GOOS/GOARCH
38+
# (BuildKit injects TARGETOS/TARGETARCH from the --platform flag). Cgo is
39+
# already disabled below, so cross-compile produces a working static binary
40+
# in seconds for any target arch — no QEMU, no toolchain setup.
41+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
42+
ARG TARGETOS
43+
ARG TARGETARCH
3244

3345
COPY --from=uibuilder /src /pgwatch
3446
COPY --from=uibuilder /src/internal/webui/build /pgwatch/internal/webui/build
@@ -44,7 +56,7 @@ RUN grep -q 'return fmt.Errorf("unexpected extension %s version input: %s", ext,
4456
RUN sed -i 's|return fmt.Errorf("unexpected extension %s version input: %s", ext, ver)|return nil /* skip unparseable extension version */|' \
4557
/pgwatch/internal/sources/conn.go
4658

47-
RUN cd /pgwatch && CGO_ENABLED=0 go build \
59+
RUN cd /pgwatch && CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
4860
-ldflags "-X 'main.version=3.7.0-patched'" \
4961
./cmd/pgwatch
5062

0 commit comments

Comments
 (0)