Repository navigation
feat(packaging): Add manylinux-based packaging build environment image. #20
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
bb0bff0
feat(packaging): Add a manylinux-based build-env image and CI to publ…
jackluo923 a2c3d14
ci(packaging): Validate build-env image on pull requests
jackluo923 fa12a14
refactor(packaging): Use repository root as build-env context
jackluo923 5ebfec7
refactor(packaging): Simplify build-env helper paths
jackluo923 378bb46
refactor(packaging): Simplify build-env Dockerfile
jackluo923 c86c415
refactor(packaging): Mount repository during build-env setup
jackluo923 0fb6a98
fix(packaging): Preserve build-env task metadata
jackluo923 da06102
refactor(packaging): Scope CA bundle handling to build-env
jackluo923 a087bcd
fix(packaging): Support corporate CA bundles larger than BuildKit's s…
jackluo923 14c3e7d
fix(packaging): Simplify host CA staging
jackluo923 200831a
fix(packaging): Harden build-env image context
jackluo923 ff71b50
Update tools/build-packages/dependency-image/Dockerfile
jackluo923 700fbca
Update tools/build-packages/dependency-image/Dockerfile
jackluo923 6aa6593
Update tools/build-packages/dependency-image/Dockerfile
jackluo923 bc56905
Update tools/build-packages/dependency-image/Dockerfile
jackluo923 c17fa2d
Update taskfile.yaml
jackluo923 52b0dcb
fix(packaging): exclude generated Docker context files
jackluo923 1830696
Update .github/workflows/build-dependency-image.yaml
jackluo923 54b31f0
Update .github/workflows/build-dependency-image.yaml
jackluo923 63cf47e
Update .github/workflows/build-dependency-image.yaml
jackluo923 fd3ef9f
Update .github/workflows/build-dependency-image.yaml
jackluo923 a283d8c
Update .github/workflows/build-dependency-image.yaml
jackluo923 14cd655
Update .github/workflows/build-dependency-image.yaml
jackluo923 3c05f75
Update tools/build-packages/dependency-image/utils.sh
jackluo923 6a04667
Update tools/build-packages/dependency-image/utils.sh
jackluo923 93a8273
Update tools/build-packages/build-dependency-image.sh
jackluo923 321c316
Update tools/build-packages/build-dependency-image.sh
jackluo923 7965baa
Update tools/build-packages/build-dependency-image.sh
jackluo923 5f72b86
Update tools/build-packages/build-dependency-image.sh
jackluo923 8fbbbf6
Update tools/build-packages/build-dependency-image.sh
jackluo923 561f33d
Update tools/build-packages/build-dependency-image.sh
jackluo923 c067656
Update tools/build-packages/build-dependency-image.sh
jackluo923 e6a31f2
Update tools/build-packages/build-dependency-image.sh
jackluo923 e64f0dd
Update .github/workflows/build-dependency-image.yaml
jackluo923 7df79ed
Update tools/build-packages/dependency-image/utils.sh
jackluo923 979c334
Update tools/build-packages/dependency-image/utils.sh
jackluo923 822afca
refactor(packaging): Set Task concurrency via CLI
jackluo923 ad18a28
Apply suggestion from @junhaoliao
jackluo923 39cbbe4
Apply suggestions from code review
jackluo923 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| .git | ||
| .task | ||
| build | ||
| **/target | ||
| packages-* | ||
This file contains hidden or 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,153 @@ | ||
| # Publishes the content-addressed build-env image used by package builds. | ||
| # Pull requests build the image locally without publishing it. | ||
| # | ||
| # Flow: | ||
| # plan derive the env-<hash> image reference and decide whether to build | ||
| # build validate or publish per-architecture images | ||
| # manifest publish the multi-architecture env-<hash> tag | ||
|
|
||
| name: "build-dependency-image" | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - ".github/workflows/build-dependency-image.yaml" | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| - "taskfile.yaml" | ||
| - "taskfiles/**" | ||
| - "tools/build-packages/build-dependency-image.sh" | ||
| - "tools/build-packages/dependency-image/**" | ||
| - "tools/yscope-dev-utils" | ||
| workflow_call: | ||
| outputs: | ||
| image: | ||
| description: "Fully qualified dependency image reference" | ||
| value: "${{jobs.plan.outputs.image}}" | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| # Keep direct and reusable-workflow invocations in the same concurrency group. | ||
| group: "build-dependency-image-${{github.ref}}" | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| IMAGE_NAME: "build-env" | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| jobs: | ||
| plan: | ||
| runs-on: "ubuntu-24.04" | ||
| permissions: | ||
| contents: "read" | ||
| packages: "read" | ||
| outputs: | ||
| image: "${{steps.image.outputs.ref}}" | ||
| needs-build: "${{steps.decide.outputs.needs-build}}" | ||
| steps: | ||
| - name: "Check out repository" | ||
| uses: "actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5" # v4.3.1 | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
jackluo923 marked this conversation as resolved.
Resolved
|
||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: "Resolve dependency image" | ||
| id: "image" | ||
| run: |- | ||
| source tools/build-packages/dependency-image/utils.sh | ||
| build_env_hash=$(derive_build_env_hash) | ||
| image_repo="ghcr.io/$(printf '%s' "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')" | ||
| image=$(image_ref "${image_repo}" "${IMAGE_NAME}" "${build_env_hash}") | ||
| echo "ref=${image}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: "Log in to GHCR" | ||
| if: "github.event_name != 'pull_request'" | ||
| uses: "docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9" # v3.7.0 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| with: | ||
| registry: "ghcr.io" | ||
| username: "${{github.actor}}" | ||
| password: "${{secrets.GITHUB_TOKEN}}" | ||
|
|
||
| - name: "Decide whether to build" | ||
| id: "decide" | ||
| env: | ||
| IMAGE: "${{steps.image.outputs.ref}}" | ||
| run: |- | ||
| if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | ||
| echo "::notice::Pull request validation will build ${IMAGE} locally without publishing" | ||
| needs_build=true | ||
| elif docker buildx imagetools inspect "${IMAGE}" &>/dev/null; then | ||
| echo "::notice::${IMAGE} already exists — skipping rebuild" | ||
| needs_build=false | ||
| else | ||
| echo "::notice::${IMAGE} not found — will build" | ||
| needs_build=true | ||
| fi | ||
| echo "needs-build=${needs_build}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| build: | ||
| needs: "plan" | ||
| if: "needs.plan.outputs.needs-build == 'true'" | ||
| permissions: | ||
| contents: "read" | ||
| packages: "write" | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - arch: "amd64" | ||
| runner: "ubuntu-24.04" | ||
| - arch: "arm64" | ||
| runner: "ubuntu-24.04-arm" | ||
| runs-on: "${{matrix.runner}}" | ||
| timeout-minutes: 360 | ||
|
|
||
| steps: | ||
| - name: "Check out repository" | ||
| uses: "actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5" # v4.3.1 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: "Log in to GHCR" | ||
| if: "github.event_name != 'pull_request'" | ||
| uses: "docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9" # v3.7.0 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| with: | ||
| registry: "ghcr.io" | ||
| username: "${{github.actor}}" | ||
| password: "${{secrets.GITHUB_TOKEN}}" | ||
|
|
||
| - name: "Set up Docker Buildx" | ||
| uses: "docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f" # v3.12.0 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
|
|
||
| - name: "Build per-arch dependency image" | ||
| env: | ||
| IMAGE: "${{needs.plan.outputs.image}}" | ||
| ARCH: "${{matrix.arch}}" | ||
| run: |- | ||
| source tools/build-packages/dependency-image/utils.sh | ||
| output="--push" | ||
| if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | ||
| output="--load" | ||
| fi | ||
| build_image "${IMAGE}-${ARCH}" "linux/${ARCH}" "${output}" | ||
|
|
||
| manifest: | ||
| needs: ["plan", "build"] | ||
| if: "github.event_name != 'pull_request' && needs.plan.outputs.needs-build == 'true'" | ||
| permissions: | ||
| packages: "write" | ||
| runs-on: "ubuntu-24.04" | ||
| timeout-minutes: 15 | ||
|
|
||
| steps: | ||
| - name: "Log in to GHCR" | ||
| uses: "docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9" # v3.7.0 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| with: | ||
| registry: "ghcr.io" | ||
| username: "${{github.actor}}" | ||
| password: "${{secrets.GITHUB_TOKEN}}" | ||
|
|
||
| - name: "Create multi-arch manifest" | ||
| env: | ||
| IMAGE: "${{needs.plan.outputs.image}}" | ||
| run: |- | ||
| docker buildx imagetools create \ | ||
| --tag "${IMAGE}" \ | ||
| "${IMAGE}-amd64" \ | ||
| "${IMAGE}-arm64" | ||
This file contains hidden or 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 hidden or 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 hidden or 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,82 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Resolves this repo's dependency-image reference for local builds. | ||
| # Checks local Docker first, then GHCR, then builds a host-arch image. | ||
| # | ||
| # Prints the resolved image reference to stdout. | ||
| # | ||
| # Example: | ||
| # image=$(tools/build-packages/build-dependency-image.sh) | ||
| # docker run --rm -v "$(pwd):/src" -w /src "${image}" \ | ||
| # task velox-connector:build | ||
| # | ||
| # Requires: docker (with buildx), git, sha256sum. | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
| set -o pipefail | ||
|
|
||
| script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||
| source "${script_dir}/dependency-image/utils.sh" | ||
|
|
||
| # Derive this repo's GHCR namespace from its GitHub origin remote. | ||
| image_repo_from_origin() { | ||
| local remote_url owner_repo | ||
| remote_url="$(git -C "${_REPO_ROOT}" remote get-url origin)" | ||
| case "${remote_url}" in | ||
| https://github.com/*) owner_repo="${remote_url#https://github.com/}" ;; | ||
| git@github.com:*) owner_repo="${remote_url#git@github.com:}" ;; | ||
| ssh://git@github.com/*) owner_repo="${remote_url#ssh://git@github.com/}" ;; | ||
| *) | ||
| echo "ERROR: can't derive GHCR image repo from origin remote: ${remote_url}" >&2 | ||
| echo " Expected a github.com remote." >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| exit 1 | ||
| ;; | ||
| esac | ||
| owner_repo="${owner_repo%.git}" | ||
| printf 'ghcr.io/%s\n' "$(printf '%s' "${owner_repo}" | tr '[:upper:]' '[:lower:]')" | ||
| } | ||
|
|
||
| host_platform() { | ||
| case "$(uname -m)" in | ||
| x86_64) printf 'linux/amd64\n' ;; | ||
| aarch64|arm64) printf 'linux/arm64\n' ;; | ||
| *) echo "ERROR: unsupported host arch: $(uname -m)" >&2; exit 1 ;; | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| esac | ||
| } | ||
|
|
||
| main() { | ||
| local build_env_hash image image_repo platform pull_err | ||
|
|
||
| echo "==> Deriving build-env hash..." >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| build_env_hash="$(derive_build_env_hash)" | ||
| image_repo="$(image_repo_from_origin)" | ||
| image="$(image_ref "${image_repo}" "build-env" "${build_env_hash}")" | ||
| platform="$(host_platform)" | ||
|
|
||
| echo " build-env hash: ${build_env_hash}" >&2 | ||
| echo " image: ${image}" >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
|
|
||
| if docker image inspect "${image}" &>/dev/null; then | ||
| echo "==> Found in local Docker cache." >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| echo "${image}" | ||
| return | ||
| fi | ||
|
|
||
| echo "==> Checking repository registry..." >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| if pull_err="$(docker pull "${image}" 2>&1)"; then | ||
| echo "==> Pulled from repository registry." >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| echo "${image}" | ||
| return | ||
| fi | ||
|
|
||
| echo " docker pull failed; will build from scratch. Pull error:" >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| printf '%s\n' "${pull_err}" | sed 's/^/ /' >&2 | ||
|
|
||
| echo "==> Image not available — building from scratch..." >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| build_image "${image}" "${platform}" "--load" | ||
| echo "==> Built locally." >&2 | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| echo "${image}" | ||
| } | ||
|
|
||
| main | ||
This file contains hidden or 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,50 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| FROM quay.io/pypa/manylinux_2_28:latest | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| ARG HOST_CA_BUNDLE=/run/secrets/host-ca | ||
| ARG HOST_CA_ENV=/usr/local/share/clp-plugin-presto-connector/use-host-ca.sh | ||
|
|
||
| # When available, expose the host CA bundle only to networked build steps via | ||
| # tool-specific environment variables. This supports local corporate builds | ||
| # without baking host CA certificates into the final image. | ||
| COPY tools/build-packages/dependency-image/use-host-ca.sh ${HOST_CA_ENV} | ||
|
|
||
| # Install OS packages missing from the manylinux base image. | ||
| # dnf talks to libcurl directly and ignores CURL_CA_BUNDLE/SSL_CERT_FILE, so | ||
| # it needs its own --setopt=sslcacert pointed at the host CA bundle. | ||
| RUN --mount=type=bind,from=host-ca,source=host-ca,target=${HOST_CA_BUNDLE} \ | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| . "${HOST_CA_ENV}" \ | ||
| && dnf_sslcacert_opt="" \ | ||
| && if [ -s "${HOST_CA_BUNDLE}" ]; then \ | ||
| dnf_sslcacert_opt="--setopt=sslcacert=${HOST_CA_BUNDLE}"; \ | ||
| fi \ | ||
| && dnf install -y --setopt=install_weak_deps=False ${dnf_sslcacert_opt} \ | ||
| dpkg gettext git java-17-openjdk-devel libcurl-devel libevent-devel \ | ||
| libunwind-devel ninja-build openssl-devel patchelf python3-pip rpm-build \ | ||
| && dnf clean all | ||
|
|
||
| RUN --mount=type=bind,from=host-ca,source=host-ca,target=${HOST_CA_BUNDLE} \ | ||
| . "${HOST_CA_ENV}" \ | ||
| && python3 -m pip install --no-cache-dir 'pip==21.3.1' \ | ||
| && python3 -m pip install --no-cache-dir 'cmake==3.28.*' | ||
|
|
||
| ARG GO_TASK_VERSION=v3.48.0 | ||
| ARG TARGETARCH | ||
| RUN --mount=type=bind,from=host-ca,source=host-ca,target=${HOST_CA_BUNDLE} \ | ||
| set -euxo pipefail; \ | ||
| . "${HOST_CA_ENV}"; \ | ||
| mkdir -p /opt/go-task/bin; \ | ||
| curl -fsSL "https://github.com/go-task/task/releases/download/${GO_TASK_VERSION}/task_linux_${TARGETARCH}.tar.gz" \ | ||
| | tar xz -C /opt/go-task/bin task | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
|
|
||
| ENV PATH=/opt/go-task/bin:${PATH} | ||
|
|
||
| ENV CLP_PLUGIN_BUILD_DIR=/opt/clp-plugin-presto-connector/build | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| ENV TASK_TEMP_DIR=/opt/clp-plugin-presto-connector/.task | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
|
|
||
| # Build one dependency at a time to avoid excessive memory usage from parallel builds. | ||
| RUN --mount=type=bind,source=.,target=/repo,readonly \ | ||
| --mount=type=bind,from=host-ca,source=host-ca,target=${HOST_CA_BUNDLE} \ | ||
| . "${HOST_CA_ENV}" \ | ||
| && TASK_CONCURRENCY=1 task -d /repo velox-connector:deps:install-all | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
This file contains hidden or 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,7 @@ | ||
| if [ -s "${HOST_CA_BUNDLE}" ]; then | ||
|
jackluo923 marked this conversation as resolved.
Resolved
|
||
| export CURL_CA_BUNDLE="${HOST_CA_BUNDLE}" | ||
| export GIT_SSL_CAINFO="${HOST_CA_BUNDLE}" | ||
| export PIP_CERT="${HOST_CA_BUNDLE}" | ||
| export REQUESTS_CA_BUNDLE="${HOST_CA_BUNDLE}" | ||
| export SSL_CERT_FILE="${HOST_CA_BUNDLE}" | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.