-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(infra): add Dockerfile for build
Up until now pg_idkit was hard to use from a dockerized environment without building a custom image and adding the dockerfile explicitly. This commit adds a Dockerfile and related build machinery which creates a Postgres image with pg_idkit pre-installed and usable. Along with building locally, the pg_idkit repository will also build and push images on release tags. Signed-off-by: vados <[email protected]>
- Loading branch information
Showing
6 changed files
with
197 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Build pg_idkit container | ||
|
||
on: | ||
- push | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.config.gh.runner }} | ||
matrix: | ||
config: | ||
- triple: x86_64-unknown-linux-musl | ||
gh: | ||
runner: ubuntu-22.04 | ||
container: | ||
arch: amd64 | ||
pg_version: 15.5 | ||
os_version: alpine3.18 | ||
|
||
# - triple: x86_64-unknown-linux-gnu | ||
# gh_runner: ubuntu-22.04 | ||
# pg_img_version: 15.5 | ||
# os_img_version: | ||
# container: | ||
# arch: amd64 | ||
|
||
# - triple: x86_64-unknown-linux-gnu | ||
# runner: ubuntu-22.04 | ||
# os: alpine | ||
# container_arch: amd64 | ||
|
||
# - triple: aarch64-unknown-linux-gnu | ||
# runner: ubuntu-latest | ||
# os: alpine | ||
# arch: aarch64 | ||
# - triple: aarch64-unknown-linux-musl | ||
# runner: ubuntu-latest | ||
# os: alpine | ||
# arch: aarch64 | ||
# - triple: aarch64-apple-darwin | ||
# runner: macos-12 | ||
# os: alpine | ||
# arch: aarch64 | ||
# - triple: x86_64-apple-darwin | ||
# runner: macos-12 | ||
# os: alpine | ||
# arch: aarch64 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: docker/setup-qemu-action@v3 | ||
- uses: extractions/setup-just@v1 | ||
|
||
# - name: Switch docker buildx | ||
# run: docker buildx create --name buildx --use | ||
|
||
- name: Build the multi-platform image | ||
run: just image | ||
env: | ||
CONTAINER_IMAGE_ARCH: ${{ matrix.config.container.arch }} | ||
POSTGRES_IMAGE_VERSION: ${{ matrix.config.container.pg_version }} | ||
POSTGRES_OS_IMAGE_VERSION: ${{ matrix.config.container.os_version }} | ||
|
||
# env: | ||
# DOCKER_PLATFORM_ARG: >- | ||
# --platform linux/amd64,linux/arm64,linux/arm/v7 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM postgres:15.5-alpine3.18@sha256:a57387207806d947c842f1be9f358e37b05442bf8b5ed19b1a69af281be930e7 AS builder | ||
|
||
ARG RUST_TOOLCHAIN_VERSION=1.74 | ||
ARG PGRX_PG_VERSION=pg15 | ||
|
||
# Install OS deps | ||
RUN apk add --no-cache \ | ||
alpine-sdk \ | ||
clang \ | ||
clang-dev \ | ||
clang-libs \ | ||
musl-dev \ | ||
openssl-dev \ | ||
rustup | ||
|
||
# Install Rust & related deps | ||
RUN rustup-init -y --profile minimal --default-toolchain $RUST_TOOLCHAIN_VERSION \ | ||
&& source "$HOME/.cargo/env" \ | ||
&& cargo install cargo-binstall | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
RUN cargo binstall -y just | ||
|
||
# Install pgrx | ||
# (disabling the static C runtime is required since pgrx requires dynamic linking w/ libssl and libcrypto) | ||
RUN RUSTFLAGS="-Ctarget-feature=-crt-static" cargo install cargo-pgrx | ||
|
||
# Copy in pg_idkit code | ||
WORKDIR /pg_idkit | ||
COPY . . | ||
|
||
# Perform the build and packaging of pg_idkit | ||
ENV PGRX_IGNORE_RUST_VERSIONS=y | ||
ENV PKG_PG_CONFIG_PATH=/usr/local/bin/pg_config | ||
RUN cargo pgrx init --pg15=$PKG_PG_CONFIG_PATH | ||
RUN RUSTFLAGS="-Ctarget-feature=-crt-static" just build package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# NOTE: you must have the base packaging layer built for this image to work | ||
# you can build this from scratch with `just build-base-pkg-image` | ||
# | ||
FROM ghcr.io/vadosware/pg_idkit/base-pkg:pg15.5-alpine3.18-amd64 AS builder | ||
|
||
# Re-run the build with the latest code | ||
WORKDIR /pg_idkit | ||
COPY . . | ||
RUN RUSTFLAGS="-Ctarget-feature=-crt-static" just build package | ||
|
||
FROM postgres:15.5-alpine3.18@sha256:a57387207806d947c842f1be9f358e37b05442bf8b5ed19b1a69af281be930e7 | ||
|
||
# NOTE: PGRX_PG_VERSION is defined via base-pkg:pg15.5-alpine3.18-amd64 | ||
ARG PGRX_PG_VERSION=pg15 | ||
ARG PGIDKIT_REVISION | ||
|
||
# Copy relevant built-files | ||
COPY --from=builder /pg_idkit/target/release/pg_idkit-${PGRX_PG_VERSION}/usr /usr | ||
|
||
# expected @ /usr/local/share/postgresql/extension | ||
# actually @ ./local/share/postgresql/extension/pg_idkit.control | ||
|
||
ARG PGIDKIT_VERSION | ||
ARG PGIDKIT_REVISION | ||
|
||
LABEL org.opencontainers.image.authors="Victor Adossi <[email protected]>" | ||
LABEL org.opencontainers.image.description="A distribution of the base postgres image, with pg_idkit pre-installed." | ||
LABEL org.opencontainers.image.documentation="https://github.com/VADOSWARE/pg_idkit#readme" | ||
LABEL org.opencontainers.image.licenses="Apache-2.0" | ||
LABEL org.opencontainers.image.revision=$PGIDKIT_REVISION | ||
LABEL org.opencontainers.image.source="https://github.com/VADOSWARE/pg_idkit" | ||
LABEL org.opencontainers.image.title="Postgres + pg_idkit" | ||
LABEL org.opencontainers.image.url="https://github.com/VADOSWARE/pg_idkit" | ||
LABEL org.opencontainers.image.vendor="VADOSWARE" | ||
LABEL org.opencontainers.image.version=v${PGIDKIT_VERSION} |