Skip to content

Commit fc03746

Browse files
authored
Merge pull request #256 from launchql/anmol/docker-fixes-update
feature: update dockerfile to proper user and other requirements for cloudnative-pg
2 parents 91fbcb2 + c4f140f commit fc03746

File tree

8 files changed

+180
-105
lines changed

8 files changed

+180
-105
lines changed

.github/workflows/build-docker.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Docker LaunchQL
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- v1
8+
- release/*
9+
pull_request:
10+
branches:
11+
- main
12+
- v1
13+
types: [opened, reopened, synchronize, ready_for_review]
14+
workflow_dispatch: {}
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}-docker-launchql
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build-push-launchql:
22+
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
23+
runs-on: ubuntu-latest
24+
25+
permissions:
26+
contents: read
27+
packages: write
28+
29+
env:
30+
REPO: ghcr.io/${{ github.repository_owner }}
31+
PLATFORMS: linux/amd64,linux/arm64
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Set up QEMU
38+
uses: docker/setup-qemu-action@v3
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Login to GHCR
44+
if: github.event_name != 'pull_request'
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ghcr.io
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Extract metadata
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ${{ env.REPO }}/launchql
56+
tags: |
57+
type=ref,event=branch
58+
type=ref,event=pr
59+
type=semver,pattern={{version}}
60+
type=semver,pattern={{major}}.{{minor}}
61+
type=sha,format=short,prefix=
62+
type=raw,value=latest,enable={{is_default_branch}}
63+
64+
- name: Build and push
65+
uses: docker/build-push-action@v5
66+
with:
67+
context: .
68+
file: ./Dockerfile
69+
platforms: ${{ env.PLATFORMS }}
70+
push: ${{ github.event_name != 'pull_request' }}
71+
tags: ${{ steps.meta.outputs.tags }}
72+
labels: ${{ steps.meta.outputs.labels }}
73+
cache-from: type=gha
74+
cache-to: type=gha,mode=max

.github/workflows/docker.yaml

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ on:
2020
workflow_dispatch:
2121
inputs:
2222
process:
23-
description: 'Process to build (pgvector | node-sqitch | postgis | pgvector-postgis | launchql)'
23+
description: 'Process to build (pgvector | node-sqitch | postgis | pgvector-postgis)'
2424
type: choice
2525
required: true
2626
options:
2727
- pgvector
2828
- node-sqitch
2929
- postgis
3030
- pgvector-postgis
31-
- launchql
3231
default: pgvector
3332
version:
3433
description: 'Specific version to build (must exist in version.yaml)'
@@ -96,55 +95,3 @@ jobs:
9695
REPO_NAME=$REPO \
9796
PLATFORMS="$PLATFORMS" \
9897
build-push-process
99-
100-
build-launchql:
101-
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
102-
runs-on: ubuntu-latest
103-
104-
permissions:
105-
contents: read
106-
packages: write
107-
108-
defaults:
109-
run:
110-
working-directory: docker
111-
112-
env:
113-
REPO: ghcr.io/${{ github.repository_owner }}
114-
PLATFORMS: linux/amd64,linux/arm64
115-
116-
steps:
117-
- name: Checkout
118-
uses: actions/checkout@v4
119-
120-
- name: Set up QEMU
121-
uses: docker/setup-qemu-action@v3
122-
123-
- name: Set up Docker Buildx
124-
uses: docker/setup-buildx-action@v3
125-
126-
- name: Login to GHCR
127-
if: github.event_name != 'pull_request'
128-
uses: docker/login-action@v3
129-
with:
130-
registry: ghcr.io
131-
username: ${{ github.actor }}
132-
password: ${{ secrets.GITHUB_TOKEN }}
133-
134-
- name: Build LaunchQL (no push)
135-
if: github.event_name == 'pull_request'
136-
run: |
137-
make \
138-
PROCESS=launchql \
139-
REPO_NAME=$REPO \
140-
PLATFORMS="$PLATFORMS" \
141-
build-process
142-
143-
- name: Build and push LaunchQL (all versions)
144-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
145-
run: |
146-
make \
147-
PROCESS=launchql \
148-
REPO_NAME=$REPO \
149-
PLATFORMS="$PLATFORMS" \
150-
build-push-process
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ RUN set -eux; \
5454

5555
ENTRYPOINT ["/usr/local/bin/lql"]
5656
CMD ["--help"]
57+

docker/Makefile

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ PLATFORMS?=linux/arm64
77
# default process if none specified (can be overridden: `make PROCESS=postgis build-process`)
88
PROCESS?=pgvector
99

10-
# Convenience: list of known processes
11-
PROCESSES:=pgvector node-sqitch postgis pgvector-postgis launchql
10+
# Convenience: list of known processes (launchql moved to root Dockerfile)
11+
PROCESSES:=pgvector node-sqitch postgis pgvector-postgis
1212

1313
CONTAINER_NAME?=$(PROCESS)
1414

@@ -54,42 +54,28 @@ build-process-version:
5454
@test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; }
5555
@test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; }
5656
@echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (build)"
57-
@DOCKERFILE_PATH="$(PROCESS)/Dockerfile"; \
58-
CONTEXT=$$( \
59-
if [ "$(PROCESS)" = "launchql" ]; then \
60-
echo ".."; \
61-
else \
62-
echo "$(PROCESS)"; \
63-
fi ); \
64-
docker buildx build \
57+
@docker buildx build \
6558
--platform $(PLATFORMS) \
6659
--build-arg BASE=$(BASE) \
6760
--build-arg BASE_VERSION=$(VERSION) \
68-
--file $$DOCKERFILE_PATH \
61+
--file $(PROCESS)/Dockerfile \
6962
-t $(REPO_NAME)/$(PROCESS):$(VERSION) \
70-
$$CONTEXT
63+
$(PROCESS)
7164

7265
# Build+push only a specific VERSION for $(PROCESS). Intended for internal use by build-push-process.
7366
# Usage (internal): $(MAKE) BASE=<base> VERSION=<version> build-push-process-version
7467
build-push-process-version:
7568
@test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; }
7669
@test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; }
7770
@echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (push)"
78-
@DOCKERFILE_PATH="$(PROCESS)/Dockerfile"; \
79-
CONTEXT=$$( \
80-
if [ "$(PROCESS)" = "launchql" ]; then \
81-
echo ".."; \
82-
else \
83-
echo "$(PROCESS)"; \
84-
fi ); \
85-
docker buildx build \
71+
@docker buildx build \
8672
--platform $(PLATFORMS) \
8773
--build-arg BASE=$(BASE) \
8874
--build-arg BASE_VERSION=$(VERSION) \
89-
--file $$DOCKERFILE_PATH \
75+
--file $(PROCESS)/Dockerfile \
9076
-t $(REPO_NAME)/$(PROCESS):$(VERSION) \
9177
--push \
92-
$$CONTEXT
78+
$(PROCESS)
9379

9480
# Aliases
9581
all: build-all
@@ -107,6 +93,3 @@ postgis:
10793

10894
pgvector-postgis:
10995
$(MAKE) PROCESS=pgvector-postgis build-process
110-
111-
launchql:
112-
$(MAKE) PROCESS=launchql build-process

docker/README.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,78 @@
11

2-
# Docker Image
2+
# Docker Images
3+
4+
This directory contains Dockerfiles for PostgreSQL-based images that extend the official PostgreSQL images with additional extensions and tools.
5+
6+
## Available Images
7+
8+
- **pgvector** - PostgreSQL with pgvector extension for vector similarity search
9+
- **postgis** - PostgreSQL with PostGIS extension for spatial/geographic data
10+
- **pgvector-postgis** - PostgreSQL with both pgvector and PostGIS extensions, plus CloudNativePG compatibility (pgaudit, pg-failover-slots, barman-cloud)
11+
- **node-sqitch** - Node.js with Sqitch for database change management
12+
13+
## LaunchQL Main Image
14+
15+
The main LaunchQL application image (built from the codebase) is now at the **root** of the repository:
16+
- **Dockerfile**: `/Dockerfile` (root level)
17+
- **GitHub Action**: `.github/workflows/docker-launchql.yaml`
18+
19+
The base image and version are specified directly in the Dockerfile using ARG directives. This separation keeps codebase-dependent images separate from extension-only images.
20+
21+
## Building Images
22+
23+
### Building Extension Images (this directory)
24+
25+
```bash
26+
# Build a specific process
27+
make PROCESS=pgvector build-process
28+
29+
# Build all processes
30+
make build-all
31+
32+
# Build and push a specific process
33+
make PROCESS=pgvector-postgis build-push-process
34+
35+
# Build and push all processes
36+
make build-push-all
37+
```
38+
39+
### Building LaunchQL Image (root level)
40+
41+
```bash
42+
# From the root of the repository (uses default versions from Dockerfile)
43+
docker buildx build \
44+
--platform linux/amd64,linux/arm64 \
45+
--file Dockerfile \
46+
-t ghcr.io/launchql/launchql:latest \
47+
.
48+
49+
# Or override base/version with build args
50+
docker buildx build \
51+
--platform linux/amd64,linux/arm64 \
52+
--build-arg BASE=node \
53+
--build-arg BASE_VERSION=22-bookworm \
54+
--file Dockerfile \
55+
-t ghcr.io/launchql/launchql:22-bookworm \
56+
.
57+
```
58+
59+
## GitHub Actions
60+
61+
- **docker.yaml** - Builds extension images from this directory (pgvector, postgis, etc.)
62+
- **docker-launchql.yaml** - Builds the main LaunchQL image from the root Dockerfile
63+
64+
## Version Configuration
65+
66+
Each image directory contains a `version.yaml` file that specifies:
67+
- `base`: The base Docker image to use
68+
- `versions`: List of version tags to build
69+
70+
Example:
71+
```yaml
72+
base: postgres
73+
versions:
74+
- 14
75+
- 15
76+
- 16
77+
```
378

docker/launchql/version.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

docker/pgvector-postgis/Dockerfile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
ARG BASE=postgres
22
ARG BASE_VERSION=14
3+
ARG BARMAN_VERSION=3.14.0
34
FROM ${BASE}:${BASE_VERSION}
45

56
LABEL org.opencontainers.image.source="https://github.com/launchql/launchql"
67
ARG BASE
78
ARG BASE_VERSION
9+
ARG BARMAN_VERSION
810
ENV BASE_VERSION=${BASE_VERSION}
11+
ENV PIP_BREAK_SYSTEM_PACKAGES=1
912

1013
# Debian-based: install both pgvector and postgis from PGDG per-PG-major
14+
# Plus CloudNativePG requirements: pgaudit, pg-failover-slots, barman-cloud
1115
RUN set -eux; \
1216
export DEBIAN_FRONTEND=noninteractive; \
1317
apt-get update; \
@@ -24,7 +28,22 @@ RUN set -eux; \
2428
postgresql-${PG_MAJOR}-postgis-3-scripts \
2529
postgis \
2630
postgresql-${PG_MAJOR}-pgvector \
31+
postgresql-${PG_MAJOR}-pgaudit \
32+
postgresql-${PG_MAJOR}-pg-failover-slots \
33+
locales-all \
34+
build-essential \
35+
python3-dev \
36+
python3-pip \
37+
python3-psycopg2 \
38+
python3-setuptools \
2739
make \
2840
bash; \
29-
rm -rf /var/lib/apt/lists/*
41+
pip3 install --no-cache-dir barman[cloud,azure,snappy,google,zstandard,lz4]==${BARMAN_VERSION}; \
42+
apt-get remove -y --purge --autoremove build-essential python3-dev; \
43+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
44+
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
3045

46+
# Change postgres user to UID 26 for CloudNativePG compatibility
47+
RUN usermod -u 26 postgres
48+
49+
USER 26

0 commit comments

Comments
 (0)