From 90f9f88da483b34d9b1cb80b72e883a6f3c20db2 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Mon, 22 Mar 2021 15:00:32 +0100 Subject: [PATCH] feat: prepare for multiarch (#2) --- .github/workflows/build.yml | 16 ++++++---------- Dockerfile | 4 ++-- README.md | 9 ++++++--- bin/builder.sh | 5 +++-- bin/install-builder.sh | 3 +++ 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08679e7..df2e4a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,28 +14,24 @@ jobs: strategy: matrix: - flavor: [focal, bionic] + distro: [focal, bionic] + arch: [x86_64] env: - FLAVOR: ${{ matrix.flavor }} # build target, name required by binary-builder + DISTRO: ${{ matrix.distro }} # build target, name required by binary-builder + ARCH: ${{ matrix.arch }} # build target, name required by binary-builder steps: - uses: actions/checkout@v2.3.4 - - name: docker-config - uses: renovatebot/internal-tools@v1.5.0 - with: - command: docker-config - - name: binary-builder - uses: renovatebot/internal-tools@v1.5.0 + uses: renovatebot/internal-tools@v1.5.2 with: command: binary-builder dry-run: ${{github.ref != 'refs/heads/main'}} - build-args: FLAVOR token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v2.2.2 with: - name: ${{ env.FLAVOR }} + name: ${{ env.DISTRO }} path: .cache/*.tar.xz diff --git a/Dockerfile b/Dockerfile index 677280f..6cea4da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ #-------------------------------------- # Ubuntu flavor #-------------------------------------- -ARG FLAVOR +ARG DISTRO #-------------------------------------- # base images @@ -13,7 +13,7 @@ FROM ubuntu:focal@sha256:b4f9e18267eb98998f6130342baacaeb9553f136142d40959a1b46d #-------------------------------------- # builder images #-------------------------------------- -FROM build-${FLAVOR} as builder +FROM build-${DISTRO} as builder ENTRYPOINT [ "dumb-init", "--", "builder.sh" ] diff --git a/README.md b/README.md index 8d00e75..5aad32f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Prebuild Ruby releases used by [containerbase/buildpack](https://github.com/cont Build the image ```bash -docker build -t builder --build-arg APT_PROXY=http://apt-proxy:3142 . +docker build -t builder --build-arg APT_PROXY=http://apt-proxy:3142 --build-arg DISTRO=focal . ``` Test the image @@ -24,5 +24,8 @@ docker run --rm -it -v ${PWD}/.cache:/cache -e DEBURG=true builder 3.0.0 Optional environment variables -- `APT_PROXY`: Set an APT http proxy for installing build deps -- `DEBUG`: Show verbose php build output +| Name | Description | Default | +| ----------- | ------------------------------------------------------------- | --------- | +| `DISTRO` | Set an ubuntu base distro, `focal` and `bionic` are supported | `focal` | +| `APT_PROXY` | Set an APT http proxy for installing build deps | `` | +| `DEBUG` | Show verbose php build output | `` | diff --git a/bin/builder.sh b/bin/builder.sh index 88e24cc..1daed77 100755 --- a/bin/builder.sh +++ b/bin/builder.sh @@ -7,6 +7,7 @@ VERSION=${1} CODENAME=$(. /etc/os-release && echo ${VERSION_CODENAME}) NAME=ruby +ARCH=$(uname -p) BUILD_ARGS= if [[ "${DEBUG}" == "true" ]]; then @@ -18,5 +19,5 @@ ruby-build ${BUILD_ARGS} ${VERSION} /usr/local/${NAME}/${VERSION} /usr/local/${NAME}/${VERSION}/bin/ruby -v -echo "Compressing ${NAME} ${VERSION} for ${CODENAME}" -tar -cJf /cache/${NAME}-${VERSION}-${CODENAME}.tar.xz -C /usr/local/${NAME} ${VERSION} +echo "Compressing ${NAME} ${VERSION} for ${CODENAME}-${ARCH}" +tar -cJf /cache/${NAME}-${VERSION}-${CODENAME}-${ARCH}.tar.xz -C /usr/local/${NAME} ${VERSION} diff --git a/bin/install-builder.sh b/bin/install-builder.sh index 68d00c7..002afee 100755 --- a/bin/install-builder.sh +++ b/bin/install-builder.sh @@ -30,6 +30,9 @@ PREFIX=/usr/local ./ruby-build/install.sh mkdir -p /usr/local/ruby /cache +#-------------------------------- +# cleanup +#-------------------------------- if [[ ! -z "${APT_PROXY+x}" ]]; then rm -f /etc/apt/apt.conf.d/99buildpack-proxy.conf fi