diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5a4f1b4..4ee80e6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,7 +16,7 @@ jobs: - 1.73 container: - image: "ghcr.io/vadosware/pg_idkit/builder:0.x.x" + image: "ghcr.io/vadosware/pg_idkit/builder:0.1.x" credentials: username: ${{ github.actor }} password: ${{ secrets.DOCKER_BUILDER_IMAGE_PULL_PAT }} diff --git a/Justfile b/Justfile index 567f3c7..93727ab 100644 --- a/Justfile +++ b/Justfile @@ -114,17 +114,16 @@ docker-login: docker_platform_arg := env_var_or_default("DOCKER_PLATFORM_ARG", "") docker_progress_arg := env_var_or_default("DOCKER_PROGRESS_ARG", "") -# Build the docker image for pg_idkit -build-image: - {{docker}} build {{docker_platform_arg}} {{docker_progress_arg}} -f {{img_dockerfile_path}} -t {{pgidkit_image_name_full}} --build-arg PGIDKIT_REVISION={{revision}} . - -# Push the docker image for pg_idkit -push-image: - {{docker}} push {{pgidkit_image_name_full}} +##################### +# Docker Image - ci # +##################### +# +# This image is used as a cache for speeding up CI builds +# ci_dockerfile_path := env_var_or_default("CI_DOCKERFILE_PATH", "infra" / "docker" / "ci.Dockerfile") ci_image_name := env_var_or_default("CI_IMAGE_NAME", "ghcr.io/vadosware/pg_idkit/builder") -ci_image_tag := env_var_or_default("CI_IMAGE_TAG", "0.x.x") +ci_image_tag := env_var_or_default("CI_IMAGE_TAG", "0.1.x") ci_image_name_full := env_var_or_default("CI_IMAGE_NAME_FULL", ci_image_name + ":" + ci_image_tag) # Build the docker image used in CI @@ -135,6 +134,14 @@ build-ci-image: push-ci-image: {{docker}} push {{ci_image_name_full}} +########################### +# Docker Image - base-pkg # +########################### +# +# This image is used as a base for packaging flows, usually while building +# the end-user facing Docker image that is contains Postgres & pg_idkit +# + # Determine the Dockerfile to use when building the packaging utility base image base_pkg_dockerfile_path := if pg_os_image_version == "alpine3.18" { "infra/docker/base-pkg-alpine3.18.Dockerfile" @@ -144,7 +151,9 @@ base_pkg_dockerfile_path := if pg_os_image_version == "alpine3.18" { error("invalid pg_os_image_version") } base_pkg_image_name := env_var_or_default("PKG_IMAGE_NAME", "ghcr.io/vadosware/pg_idkit/base-pkg") -base_pkg_image_name_full := env_var_or_default("PKG_IMAGE_NAME_FULL", base_pkg_image_name + ":" + pgidkit_image_tag) +base_pkg_version := env_var_or_default("PKG_IMAGE_NAME", "0.1.x") +base_pkg_image_tag := env_var_or_default("POSGRES_IMAGE_VERSION", base_pkg_version + "-" + "pg" + pg_image_version + "-" + pg_os_image_version + "-" + container_img_arch) +base_pkg_image_name_full := env_var_or_default("PKG_IMAGE_NAME_FULL", base_pkg_image_name + ":" + base_pkg_image_tag) # Build the base image for packaging build-base-pkg-image: @@ -153,3 +162,19 @@ build-base-pkg-image: # Push the base image for packaging push-base-pkg-image: {{docker}} push {{base_pkg_image_name_full}} + +########################### +# Docker Image - pg_idkit # +########################### +# +# This image is the pg_idkit image itself, normally built FROM +# a image of base-pkg +# + +# Build the docker image for pg_idkit +build-image: + {{docker}} build {{docker_platform_arg}} {{docker_progress_arg}} -f {{img_dockerfile_path}} -t {{pgidkit_image_name_full}} --build-arg PGIDKIT_REVISION={{revision}} . + +# Push the docker image for pg_idkit +push-image: + {{docker}} push {{pgidkit_image_name_full}} diff --git a/infra/docker/ci.Dockerfile b/infra/docker/ci.Dockerfile index 5ed2e36..d8c227e 100644 --- a/infra/docker/ci.Dockerfile +++ b/infra/docker/ci.Dockerfile @@ -7,7 +7,8 @@ ENV SCCACHE_DIR=/usr/local/sccache # Install deps RUN apt update && apt install -y libssl-dev git openssh-client pkg-config curl ca-certificates gnupg wget -RUN cargo install sccache +RUN cargo install cargo-binstall +RUN cargo binstall -y sccache --locked ENV CARGO_BUILD_RUSTC_WRAPPER=/usr/local/cargo/bin/sccache @@ -45,7 +46,6 @@ RUN apt-get update && \ curl libreadline6-dev zlib1g-dev libclang-dev \ pkg-config cmake nodejs - # Add postgres user to root group RUN useradd --user-group --system --create-home --no-log-init idkit && \ usermod -aG sudo idkit && \ @@ -64,10 +64,16 @@ RUN chmod g+w -R /usr/share/postgresql/**/extension && \ RUN chmod g+w -R /usr/local/cargo RUN chmod g+w -R /usr/local/build +RUN mkdir /usr/local/sccache +RUN chmod g+w -R /usr/local/sccache + # Install development/build/testing deps -# NOTE: version of cargo-pgrx must be handled speicfically -RUN su idkit -c "cargo install sccache cargo-cache cargo-pgrx@0.11.0" +# NOTE: version of cargo-pgrx must be handled specifically +RUN su idkit -c "cargo install binstall" -# Initialize pgrx +# Install & Initialize pgrx # NOTE: pgrx must be reinitialized if cargo-pgrx changes +RUN su idkit -c "cargo install cargo-pgrx@0.11.0" RUN su idkit -c "cargo pgrx init --pg15 download" + +RUN su idkit -c "cargo binstall -y sccache cargo-cache cargo-get" diff --git a/infra/docker/pg15.5-alpine3.18-amd64.Dockerfile b/infra/docker/pg15.5-alpine3.18-amd64.Dockerfile index 12e3e2e..edccad9 100644 --- a/infra/docker/pg15.5-alpine3.18-amd64.Dockerfile +++ b/infra/docker/pg15.5-alpine3.18-amd64.Dockerfile @@ -2,7 +2,7 @@ # 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 +FROM ghcr.io/vadosware/pg_idkit/base-pkg:0.1.x-pg15.5-alpine3.18-amd64 AS builder # Re-run the build with the latest code WORKDIR /pg_idkit