-
Notifications
You must be signed in to change notification settings - Fork 5
docker: add new way to build and push docker images, #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
c989115
e4a515d
5e972db
89aa230
a032c62
792471e
5d05208
9e555dd
4758eac
b55db9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| name: Docker | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - v1 | ||
| - release/* | ||
| paths: | ||
| - "docker/**" | ||
| - ".github/workflows/docker.yaml" | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - v1 | ||
| paths: | ||
| - "docker/**" | ||
| - ".github/workflows/docker.yaml" | ||
| types: [opened, reopened, synchronize, ready_for_review] | ||
| workflow_dispatch: | ||
| inputs: | ||
| process: | ||
| description: 'Process to build (pgvector | node-sqitch | postgis)' | ||
| type: choice | ||
| required: true | ||
| options: | ||
| - pgvector | ||
| - node-sqitch | ||
| - postgis | ||
| default: pgvector | ||
| version: | ||
| description: 'Specific version to build (must exist in version.yaml)' | ||
| type: string | ||
| required: true | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-docker | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-push: | ||
| if: github.event_name != 'pull_request' || !github.event.pull_request.draft | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: docker | ||
|
|
||
| strategy: | ||
| matrix: | ||
| process: [pgvector, node-sqitch, postgis] | ||
| max-parallel: 3 | ||
|
|
||
| env: | ||
| REPO: ghcr.io/${{ github.repository_owner }} | ||
| PLATFORMS: linux/amd64,linux/arm64 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Login to GHCR | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build (no push) | ||
| if: github.event_name == 'pull_request' | ||
| run: | | ||
| make \ | ||
| PROCESS=${{ matrix.process }} \ | ||
| REPO_NAME=$REPO \ | ||
| PLATFORMS="$PLATFORMS" \ | ||
| build-process | ||
| - name: Build and push (all versions) | ||
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | ||
| run: | | ||
| make \ | ||
| PROCESS=${{ matrix.process }} \ | ||
| REPO_NAME=$REPO \ | ||
| PLATFORMS="$PLATFORMS" \ | ||
| build-push-process | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,90 @@ | ||
| .PHONY: all push-all node-sqitch pgvector clean | ||
| .PHONY: all push-all build-all build-push-all build-process build-push-process \ | ||
| build-process-version build-push-process-version pgvector node-sqitch postgis clean | ||
|
|
||
| all: | ||
| $(MAKE) -C node-sqitch build | ||
| $(MAKE) -C pgvector build | ||
| REPO_NAME?=pyramation | ||
| PLATFORMS?=linux/arm64 | ||
|
|
||
| push-all: | ||
| $(MAKE) -C node-sqitch push | ||
| $(MAKE) -C pgvector push | ||
| # default process if none specified (can be overridden: `make PROCESS=postgis build-process`) | ||
| PROCESS?=pgvector | ||
|
|
||
| node-sqitch: | ||
| $(MAKE) -C node-sqitch build | ||
| # Convenience: list of known processes | ||
| PROCESSES:=pgvector node-sqitch postgis | ||
|
|
||
| CONTAINER_NAME?=$(PROCESS) | ||
|
|
||
| ## build-process builds docker image(s) for $(PROCESS) using base+versions from version.yaml | ||
| ## It will build one image per version listed in $(PROCESS)/version.yaml and tag as <repo>/<process>:<version> | ||
| build-process: | ||
| @echo "==> Building process: $(PROCESS)" | ||
| @BASE=$$(sed -n 's/^base:[[:space:]]*//p' $(PROCESS)/version.yaml | head -n1); \ | ||
| VERSIONS=$$(sed -n '/^versions:/,$$p' $(PROCESS)/version.yaml | sed -n 's/^-\s*//p'); \ | ||
| if [ -z "$$BASE" ] || [ -z "$$VERSIONS" ]; then \ | ||
|
||
| echo "Error: Could not parse base or versions from $(PROCESS)/version.yaml" 1>&2; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| for v in $$VERSIONS; do \ | ||
| $(MAKE) --no-print-directory BASE=$$BASE VERSION=$$v build-process-version || exit $$?; \ | ||
| done | ||
|
|
||
| build-all: | ||
| @for p in $(PROCESSES); do \ | ||
| $(MAKE) --no-print-directory PROCESS=$$p build-process || exit $$?; \ | ||
| done | ||
|
|
||
| build-push-process: | ||
| @echo "==> Building+Pushing process: $(PROCESS)" | ||
| @BASE=$$(sed -n 's/^base:[[:space:]]*//p' $(PROCESS)/version.yaml | head -n1); \ | ||
| VERSIONS=$$(sed -n '/^versions:/,$$p' $(PROCESS)/version.yaml | sed -n 's/^-\s*//p'); \ | ||
| if [ -z "$$BASE" ] || [ -z "$$VERSIONS" ]; then \ | ||
|
||
| echo "Error: Could not parse base or versions from $(PROCESS)/version.yaml" 1>&2; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| for v in $$VERSIONS; do \ | ||
| $(MAKE) --no-print-directory BASE=$$BASE VERSION=$$v build-push-process-version || exit $$?; \ | ||
| done | ||
|
|
||
| build-push-all: | ||
| @for p in $(PROCESSES); do \ | ||
| $(MAKE) --no-print-directory PROCESS=$$p build-push-process || exit $$?; \ | ||
| done | ||
|
|
||
| # Build only a specific VERSION for $(PROCESS). Intended for internal use by build-process. | ||
| # Usage (internal): $(MAKE) BASE=<base> VERSION=<version> build-process-version | ||
| build-process-version: | ||
| @test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; } | ||
| @test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; } | ||
| @echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (build)" | ||
| @docker buildx build \ | ||
| --platform $(PLATFORMS) \ | ||
| --build-arg BASE=$(BASE) \ | ||
| --build-arg BASE_VERSION=$(VERSION) \ | ||
| -t $(REPO_NAME)/$(PROCESS):$(VERSION) \ | ||
Anmol1696 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $(PROCESS) | ||
|
|
||
| # Build+push only a specific VERSION for $(PROCESS). Intended for internal use by build-push-process. | ||
| # Usage (internal): $(MAKE) BASE=<base> VERSION=<version> build-push-process-version | ||
| build-push-process-version: | ||
| @test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; } | ||
| @test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; } | ||
| @echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (push)" | ||
| @docker buildx build \ | ||
| --platform $(PLATFORMS) \ | ||
| --build-arg BASE=$(BASE) \ | ||
| --build-arg BASE_VERSION=$(VERSION) \ | ||
| -t $(REPO_NAME)/$(PROCESS):$(VERSION) \ | ||
| --push \ | ||
| $(PROCESS) | ||
|
|
||
| # Aliases | ||
| all: build-all | ||
| push-all: build-push-all | ||
|
|
||
| # Convenience per-process targets | ||
| pgvector: | ||
| $(MAKE) -C pgvector build | ||
| $(MAKE) PROCESS=pgvector build-process | ||
|
|
||
| node-sqitch: | ||
| $(MAKE) PROCESS=node-sqitch build-process | ||
|
|
||
| # Git cleanup (repo-level only) | ||
| clean: | ||
| @git reset --hard | ||
| @git ls-files --other --exclude-standard | xargs rm -f | ||
| postgis: | ||
| $(MAKE) PROCESS=postgis build-process | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,3 @@ | ||||||
| base: node | ||||||
| versions: | ||||||
| - 20.12.0-alpine3.19 | ||||||
|
||||||
| - 20.12.0-alpine3.19 | |
| - 20.12.0-alpine3.19 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,18 @@ | ||
| FROM pyramation/postgis:13.3-alpine | ||
| ARG BASE=postgres | ||
| ARG BASE_VERSION=13.3-alpine | ||
| FROM ${BASE}:${BASE_VERSION} | ||
|
|
||
| LABEL org.opencontainers.image.source="https://github.com/launchql/launchql" | ||
|
|
||
| # Install PGVector extension | ||
| RUN apk add --no-cache --virtual .build-deps \ | ||
| git \ | ||
| build-base \ | ||
| postgresql-dev \ | ||
| && git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git \ | ||
| && cd pgvector \ | ||
| && make && make install \ | ||
| && cd .. && rm -rf pgvector \ | ||
| && apk del .build-deps | ||
| bash \ | ||
| make | ||
|
|
||
| RUN git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git | ||
| RUN cd pgvector && make && make install && cd .. && rm -rf pgvector | ||
|
|
||
| RUN apk del .build-deps | ||
Anmol1696 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| base: postgres | ||
| versions: | ||
| - 13.3-alpine |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| FROM postgres:13.3-alpine | ||
| ARG BASE=postgres | ||
| ARG BASE_VERSION=13.3-alpine | ||
| FROM ${BASE}:${BASE_VERSION} | ||
|
|
||
| RUN apk add make | ||
| LABEL org.opencontainers.image.source="https://github.com/launchql/launchql" | ||
|
|
||
| RUN apk add make bash | ||
Anmol1696 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,3 @@ | ||||||
| base: postgres | ||||||
| versions: | ||||||
| - 13.3-alpine | ||||||
|
||||||
| - 13.3-alpine | |
| - 13.3-alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workflow_dispatch inputs (process, version) are defined but unused; this matrix always builds all processes, ignoring the user's selection. Gate the matrix on event type or add a dispatch-specific step/job that uses inputs.process and inputs.version (e.g., run make PROCESS='${{ inputs.process }}' VERSION='${{ inputs.version }}' build-push-process-version for workflow_dispatch).