Skip to content

Commit c989115

Browse files
committed
add new way to build and push docker images, cresate workflow to build and push docker image, add version for each of the docker
1 parent f7d2375 commit c989115

11 files changed

Lines changed: 217 additions & 134 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- v1
8+
- release/*
9+
paths:
10+
- "docker/**"
11+
- ".github/workflows/docker.yaml"
12+
pull_request:
13+
branches:
14+
- main
15+
- v1
16+
paths:
17+
- "docker/**"
18+
- ".github/workflows/docker.yaml"
19+
types: [opened, reopened, synchronize, ready_for_review]
20+
workflow_dispatch:
21+
inputs:
22+
process:
23+
description: 'Process to build (pgvector | node-sqitch | postgis)'
24+
type: choice
25+
required: true
26+
options:
27+
- pgvector
28+
- node-sqitch
29+
- postgis
30+
default: pgvector
31+
version:
32+
description: 'Specific version to build (must exist in version.yaml)'
33+
type: string
34+
required: true
35+
36+
concurrency:
37+
group: ${{ github.workflow }}-${{ github.ref }}-docker
38+
cancel-in-progress: true
39+
40+
jobs:
41+
build-push:
42+
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
43+
runs-on: ubuntu-latest
44+
45+
permissions:
46+
contents: read
47+
packages: write
48+
49+
defaults:
50+
run:
51+
working-directory: docker
52+
53+
strategy:
54+
matrix:
55+
process: [pgvector, node-sqitch, postgis]
56+
max-parallel: 3
57+
58+
env:
59+
REPO: ghcr.io/${{ github.repository_owner }}
60+
PLATFORMS: linux/amd64,linux/arm64
61+
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
66+
- name: Set up QEMU
67+
uses: docker/setup-qemu-action@v3
68+
69+
- name: Set up Docker Buildx
70+
uses: docker/setup-buildx-action@v3
71+
72+
- name: Login to GHCR
73+
if: github.event_name != 'pull_request'
74+
uses: docker/login-action@v3
75+
with:
76+
registry: ghcr.io
77+
username: ${{ github.actor }}
78+
password: ${{ secrets.GITHUB_TOKEN }}
79+
80+
- name: Build (no push)
81+
if: github.event_name == 'pull_request'
82+
run: |
83+
make \
84+
PROCESS=${{ matrix.process }} \
85+
REPO_NAME=$REPO \
86+
PLATFORMS="$PLATFORMS" \
87+
build-process
88+
89+
- name: Build and push (all versions)
90+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
91+
run: |
92+
make \
93+
PROCESS=${{ matrix.process }} \
94+
REPO_NAME=$REPO \
95+
PLATFORMS="$PLATFORMS" \
96+
build-push-process

docker/Makefile

Lines changed: 84 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,90 @@
1-
.PHONY: all push-all node-sqitch pgvector clean
1+
.PHONY: all push-all build-all build-push-all build-process build-push-process \
2+
build-process-version build-push-process-version pgvector node-sqitch postgis clean
23

3-
all:
4-
$(MAKE) -C node-sqitch build
5-
$(MAKE) -C pgvector build
4+
REPO_NAME?=pyramation
5+
PLATFORMS?=linux/arm64
66

7-
push-all:
8-
$(MAKE) -C node-sqitch push
9-
$(MAKE) -C pgvector push
7+
# default process if none specified (can be overridden: `make PROCESS=postgis build-process`)
8+
PROCESS?=pgvector
109

11-
node-sqitch:
12-
$(MAKE) -C node-sqitch build
10+
# Convenience: list of known processes
11+
PROCESSES:=pgvector node-sqitch postgis
12+
13+
CONTAINER_NAME?=$(PROCESS)
14+
15+
## build-process builds docker image(s) for $(PROCESS) using base+versions from version.yaml
16+
## It will build one image per version listed in $(PROCESS)/version.yaml and tag as <repo>/<process>:<version>
17+
build-process:
18+
@echo "==> Building process: $(PROCESS)"
19+
@BASE=$$(sed -n 's/^base:[[:space:]]*//p' $(PROCESS)/version.yaml | head -n1); \
20+
VERSIONS=$$(sed -n '/^versions:/,$$p' $(PROCESS)/version.yaml | sed -n 's/^-\s*//p'); \
21+
if [ -z "$$BASE" ] || [ -z "$$VERSIONS" ]; then \
22+
echo "Error: Could not parse base or versions from $(PROCESS)/version.yaml" 1>&2; \
23+
exit 1; \
24+
fi; \
25+
for v in $$VERSIONS; do \
26+
$(MAKE) --no-print-directory BASE=$$BASE VERSION=$$v build-process-version || exit $$?; \
27+
done
28+
29+
build-all:
30+
@for p in $(PROCESSES); do \
31+
$(MAKE) --no-print-directory PROCESS=$$p build-process || exit $$?; \
32+
done
33+
34+
build-push-process:
35+
@echo "==> Building+Pushing process: $(PROCESS)"
36+
@BASE=$$(sed -n 's/^base:[[:space:]]*//p' $(PROCESS)/version.yaml | head -n1); \
37+
VERSIONS=$$(sed -n '/^versions:/,$$p' $(PROCESS)/version.yaml | sed -n 's/^-\s*//p'); \
38+
if [ -z "$$BASE" ] || [ -z "$$VERSIONS" ]; then \
39+
echo "Error: Could not parse base or versions from $(PROCESS)/version.yaml" 1>&2; \
40+
exit 1; \
41+
fi; \
42+
for v in $$VERSIONS; do \
43+
$(MAKE) --no-print-directory BASE=$$BASE VERSION=$$v build-push-process-version || exit $$?; \
44+
done
45+
46+
build-push-all:
47+
@for p in $(PROCESSES); do \
48+
$(MAKE) --no-print-directory PROCESS=$$p build-push-process || exit $$?; \
49+
done
1350

51+
# Build only a specific VERSION for $(PROCESS). Intended for internal use by build-process.
52+
# Usage (internal): $(MAKE) BASE=<base> VERSION=<version> build-process-version
53+
build-process-version:
54+
@test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; }
55+
@test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; }
56+
@echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (build)"
57+
@docker buildx build \
58+
--platform $(PLATFORMS) \
59+
--build-arg BASE=$(BASE) \
60+
--build-arg BASE_VERSION=$(VERSION) \
61+
-t $(REPO_NAME)/$(PROCESS):$(VERSION) \
62+
$(PROCESS)
63+
64+
# Build+push only a specific VERSION for $(PROCESS). Intended for internal use by build-push-process.
65+
# Usage (internal): $(MAKE) BASE=<base> VERSION=<version> build-push-process-version
66+
build-push-process-version:
67+
@test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; }
68+
@test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; }
69+
@echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (push)"
70+
@docker buildx build \
71+
--platform $(PLATFORMS) \
72+
--build-arg BASE=$(BASE) \
73+
--build-arg BASE_VERSION=$(VERSION) \
74+
-t $(REPO_NAME)/$(PROCESS):$(VERSION) \
75+
--push \
76+
$(PROCESS)
77+
78+
# Aliases
79+
all: build-all
80+
push-all: build-push-all
81+
82+
# Convenience per-process targets
1483
pgvector:
15-
$(MAKE) -C pgvector build
84+
$(MAKE) PROCESS=pgvector build-process
85+
86+
node-sqitch:
87+
$(MAKE) PROCESS=node-sqitch build-process
1688

17-
# Git cleanup (repo-level only)
18-
clean:
19-
@git reset --hard
20-
@git ls-files --other --exclude-standard | xargs rm -f
89+
postgis:
90+
$(MAKE) PROCESS=postgis build-process

docker/node-sqitch/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
FROM node:20.12.0-alpine3.19 AS sqitch-build
1+
ARG BASE=node
2+
ARG BASE_VERSION=20.12.0-alpine3.19
3+
FROM ${BASE}:${BASE_VERSION} AS sqitch-build
24

5+
LABEL org.opencontainers.image.source="https://github.com/launchql/launchql"
36

47
# Install system dependencies.
58
WORKDIR /work
@@ -46,7 +49,11 @@ RUN apk del .build-deps
4649
################################################################################
4750
# Copy to the final image without all the build stuff.
4851

49-
FROM node:20.12.0-alpine3.19 AS sqitch
52+
ARG BASE=node
53+
ARG BASE_VERSION=20.12.0-alpine3.19
54+
FROM ${BASE}:${BASE_VERSION} AS sqitch
55+
56+
LABEL org.opencontainers.image.source="https://github.com/launchql/launchql"
5057

5158
# Install runtime system dependencies and remove unnecesary files.
5259
RUN mkdir -p /usr/share/man/man1 /usr/share/man/man7 \
@@ -82,4 +89,4 @@ ENV LESS=-R LC_ALL=C.UTF-8 LANG=C.UTF-8 SQITCH_EDITOR=vi SQITCH_PAGER=less
8289
# for gyp and such
8390
RUN apk update && apk add --no-cache bash git python3-dev make g++
8491

85-
ENTRYPOINT ["/bin/sh"]
92+
ENTRYPOINT ["/bin/sh"]

docker/node-sqitch/Makefile

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

docker/node-sqitch/version.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
base: node
2+
versions:
3+
- 20.12.0-alpine3.19

docker/pgvector/Dockerfile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
FROM pyramation/postgis:13.3-alpine
1+
ARG BASE=postgis
2+
ARG BASE_VERSION=13.3-alpine
3+
FROM ${BASE}:${BASE_VERSION}
4+
5+
LABEL org.opencontainers.image.source="https://github.com/launchql/launchql"
26

37
# Install PGVector extension
48
RUN apk add --no-cache --virtual .build-deps \
59
git \
610
build-base \
711
postgresql-dev \
8-
&& git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git \
9-
&& cd pgvector \
10-
&& make && make install \
11-
&& cd .. && rm -rf pgvector \
12-
&& apk del .build-deps
12+
bash \
13+
make
14+
15+
RUN git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git
16+
RUN cd pgvector && make && make install && cd .. && rm -rf pgvector
17+
18+
RUN apk del .build-deps

docker/pgvector/Makefile

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

docker/pgvector/version.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
base: postgis
2+
versions:
3+
- 13.3-alpine

docker/postgis/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
FROM postgres:13.3-alpine
1+
ARG BASE=postgis
2+
ARG BASE_VERSION=13.3-alpine
3+
FROM ${BASE}:${BASE_VERSION}
24

3-
RUN apk add make
5+
LABEL org.opencontainers.image.source="https://github.com/launchql/launchql"
6+
7+
RUN apk add make bash

docker/postgis/Makefile

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

0 commit comments

Comments
 (0)