Skip to content

Commit

Permalink
fix(infra): sccache install
Browse files Browse the repository at this point in the history
See related issue mozilla/sccache#1988

Signed-off-by: vados <[email protected]>
  • Loading branch information
t3hmrman committed Nov 27, 2023
1 parent 3585b41 commit 529c590
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
43 changes: 34 additions & 9 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -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}}
16 changes: 11 additions & 5 deletions infra/docker/ci.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 && \
Expand All @@ -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 [email protected]"
# 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 [email protected]"
RUN su idkit -c "cargo pgrx init --pg15 download"

RUN su idkit -c "cargo binstall -y sccache cargo-cache cargo-get"
2 changes: 1 addition & 1 deletion infra/docker/pg15.5-alpine3.18-amd64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 529c590

Please sign in to comment.