Skip to content

Commit

Permalink
Build runtime like builder
Browse files Browse the repository at this point in the history
  • Loading branch information
heerener committed Oct 3, 2024
1 parent e6cd3e4 commit 1c9477f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/spacktainer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
AWS_BUILDER_REPO_URL: ${{ secrets.AWS_ECR_URL }}/spacktainers/builder
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
BUILD_PATH: builder
BUILDAH_EXTRA_ARGS: --label org.opencontainers.image.revision="$GITHUB_SHA"
--label org.opencontainers.image.authors="$GITHUB_TRIGGERING_ACTOR"
--label org.opencontainers.image.url="https://github.com/${GITHUB_REPOSITORY}"
Expand All @@ -26,19 +27,19 @@ jobs:
# ' --label org.opencontainers.image.created="$CI_JOB_STARTED_AT"'
SPACK_DEPLOYMENT_KEY_PUB: ${{ secrets.SPACK_DEPLOYMENT_KEY_PUB }}
run: |-
echo "Creating builder"
echo "Creating ${BUILD_PATH}"
set -x
apt install -y awscli buildah podman
export STORAGE_DRIVER=vfs # allows to build inside containers without additional mounts
export BUILDAH_FORMAT=docker # enables ONBUILD instructions which are not OCI compatible
export REGISTRY_IMAGE_TAG=latest # for now
echo "${SPACK_DEPLOYMENT_KEY_PUB}" > builder/key.pub
echo "${SPACK_DEPLOYMENT_KEY_PUB}" > ${BUILD_PATH}/key.pub
aws ecr get-login-password --region us-east-1 | buildah login --username AWS --password-stdin ${AWS_ECR_URL}
# This is written like that in case $BUILDAH_EXTRA_ARGS has args that require spaces,
# which is tricky with shell variable expansion. Similar to Kaniko, see also:
# https://github.com/GoogleContainerTools/kaniko/issues/1803
export IFS=''
COMMAND="buildah bud --iidfile image_id ${BUILDAH_EXTRA_ARGS} builder"
COMMAND="buildah bud --iidfile image_id ${BUILDAH_EXTRA_ARGS} ${BUILD_PATH}"
echo "${COMMAND}"
eval "${COMMAND}"
# Sometimes buildah push fails on the first attempt
Expand All @@ -49,6 +50,7 @@ jobs:
AWS_BUILDER_REPO_URL: ${{ secrets.AWS_ECR_URL }}/spacktainers/runtime
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
BUILD_PATH: runtime
BUILDAH_EXTRA_ARGS: --label org.opencontainers.image.revision="$GITHUB_SHA"
--label org.opencontainers.image.authors="$GITHUB_TRIGGERING_ACTOR"
--label org.opencontainers.image.url="https://github.com/${GITHUB_REPOSITORY}"
Expand All @@ -59,17 +61,20 @@ jobs:
# ' --label org.opencontainers.image.created="$CI_JOB_STARTED_AT"'
run: |-
# Holy code duplication, Batman!
echo "Creating runtime"
yum install -y awscli
echo "Creating ${BUILD_PATH}"
set -x
apt install -y awscli buildah podman
export STORAGE_DRIVER=vfs # allows to build inside containers without additional mounts
export BUILDAH_FORMAT=docker # enables ONBUILD instructions which are not OCI compatible
export REGISTRY_IMAGE_TAG=latest # for now
echo "${SPACK_DEPLOYMENT_KEY_PUB}" > ${BUILD_PATH}/key.pub
aws ecr get-login-password --region us-east-1 | buildah login --username AWS --password-stdin ${AWS_ECR_URL}
# This is written like that in case $BUILDAH_EXTRA_ARGS has args that require spaces,
# which is tricky with shell variable expansion. Similar to Kaniko, see also:
# https://github.com/GoogleContainerTools/kaniko/issues/1803
export IFS=''
COMMAND="buildah bud --iidfile image_id ${BUILDAH_EXTRA_ARGS} builder"
COMMAND="buildah bud --iidfile image_id ${BUILDAH_EXTRA_ARGS} ${BUILD_PATH}"
echo "${COMMAND}"
eval "${COMMAND}"
# Sometimes buildah push fails on the first attempt
buildah push $(<image_id) "docker://${AWS_BUILDER_REPO_URL}:${REGISTRY_IMAGE_TAG}" || sleep 10; buildah push $(<image_id) "docker://${AWS_BUILDER_REPO_URL}:${REGISTRY_IMAGE_TAG}"
Expand Down

0 comments on commit 1c9477f

Please sign in to comment.