Skip to content

Commit

Permalink
feat: prepare for multiarch (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Mar 22, 2021
1 parent 3628fd2 commit 90f9f88
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#--------------------------------------
# Ubuntu flavor
#--------------------------------------
ARG FLAVOR
ARG DISTRO

#--------------------------------------
# base images
Expand All @@ -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" ]
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 | `<empty>` |
| `DEBUG` | Show verbose php build output | `<empty>` |
5 changes: 3 additions & 2 deletions bin/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ VERSION=${1}
CODENAME=$(. /etc/os-release && echo ${VERSION_CODENAME})

NAME=ruby
ARCH=$(uname -p)
BUILD_ARGS=

if [[ "${DEBUG}" == "true" ]]; then
Expand All @@ -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}
3 changes: 3 additions & 0 deletions bin/install-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 90f9f88

Please sign in to comment.