Skip to content

Commit

Permalink
now try bioconda-utils image
Browse files Browse the repository at this point in the history
  • Loading branch information
daler committed Feb 1, 2024
1 parent 000e946 commit dedefeb
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 16 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/bioconda-utils-build-env-cos7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "bioconda-utils-build-env-cos7"
on:
pull_request:
paths:
- .github/workflows/bioconda-utils-build-env-cos7.yml
- .github/workflows/generic_build.yml

jobs:
bioconda-utils-build-env-cos7:
uses: bioconda/bioconda-containers/.github/workflows/generic_build.yml@reusable-workflow-testing
with:
image_name: bioconda-utils-build-env-cos7
tags: '3.1 3 latest'
debian_version: '12.2'
archs: 'arm64 amd64'
74 changes: 58 additions & 16 deletions .github/workflows/generic_build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
on:
workflow_call:
inputs:
# target image name to build
image_name:
required: true
type: string

# target tags to build (space-separated)
tags:
required: true
type: string

# will be passed as a build-arg to Docker
busybox_version:
required: false
type: string
Expand All @@ -16,10 +21,16 @@ on:
image_prefix:
required: false
type: string
archs: # space-separated list of architectures, e.g., "arm64 amd64"

# space-separated list of architectures, e.g., "arm64 amd64"
archs:
required: true
type: string

bioconda_utils:
required: false
type: boolean

jobs:
build:
name: Generic build
Expand Down Expand Up @@ -60,15 +71,27 @@ jobs:
buildah manifest create "${image_name}:${tag}"
done
# Incrementally compose build args. Using this
archs_and_images=$archs
# ----------------------------------------------------------------------
# Incrementally compose build args, depending on which inputs were
# provided.
BUILD_ARGS=""
if [ ! -z "${debian_version}" ]; then
BUILD_ARGS=$(echo $BUILD_ARGS "--build-arg=debian_version=$debian_version")
BUILD_ARGS+="--build-arg=debian_version=$debian_version"
fi
if [ '${{ inputs.bioconda_utils }}' ]; then
# Due to different nomenclature used by conda-forge and buildah, we
# need to map archs to base images.
archs_and_images='
amd64=quay.io/condaforge/linux-anvil-cos7-x86_64
arm64=quay.io/condaforge/linux-anvil-aarch64
'
fi
# If busybox_version was specified, assume we are making a busybox image.
if [ ! -z "${busybox_version}" ]; then
BUILD_ARGS=$(echo $BUILD_ARGS "--build-arg=busybox_version=$busybox_version")
BUILD_ARGS+="--build-arg=busybox_version=$busybox_version"
# Make a busybox image that we'll use further below.
# --iidfile prints the built image ID to the specified file so we can
Expand All @@ -82,43 +105,62 @@ jobs:
rm "${iidfile}"
# And then extend the build args with this image.
BUILD_ARGS=$(echo $BUILD_ARGS "--build-arg=busybox_image=${busybox_image}")
BUILD_ARGS+="--build-arg=busybox_image=${busybox_image}"
fi
for arch in $archs ; do
# ----------------------------------------------------------------------
# Build each arch's image
for arch in $arch_and_image ; do
arch=$(echo $arch_and_image | cut -f1 -d "=")
base_image=$(echo $arch_and_image | cut -f2 -d "=")
iidfile="$( mktemp )"
buildah bud \
--arch="${arch}" \
--iidfile="${iidfile}" \
--build_arg=base_image="${base_image}" \
$BUILD_ARGS
image_id="$( cat "${iidfile}" )"
rm "${iidfile}"
# Extract various package info and version info to store as labels
# Extract various package info and version info...
container="$( buildah from "${image_id}" )"
run() { buildah run "${container}" "${@}" ; }
# Incrementally make labels
deb_list="$( run cat /.deb.lst | tr '\n' '|' | sed 's/|$//' )"
pkg_list="$( run cat /.pkg.lst | tr '\n' '|' | sed 's/|$//' )"
glibc="$( run sh -c 'exec "$( find -xdev -name libc.so.6 -print -quit )"' | sed '1!d' )"
debian="$( run cat /etc/debian_version | sed '1!d' )"
bash="$( run bash --version | sed '1!d' )"
buildah rm "${container}"
# Store package/version info as labels for the image
LABELS=""
LABELS+="--label=deb-list=${deb_list} "
LABELS+="--label=pkg-list=${pkg_list} "
LABELS+="--label=glibc=${glibc} "
LABELS+="--label=debian=${debian} "
LABELS+="--label=bash=${bash} "
if [ '${{ inputs.bioconda_utils }}' ]; then
bioconda_utils="$(
run sh -c '. /opt/conda/etc/profile.d/conda.sh && conda activate base && bioconda-utils --version' \
| rev | cut -f1 -d " " | rev
)"
LABELS+="--label=bioconda-utils=${bioconda_utils} "
fi
# ...then store that info as labels for the image
container="$( buildah from "${image_id}" )"
buildah config \
--label=glibc="${glibc}" \
--label=debian="${debian}" \
--label=bash="${bash}" \
--label=deb-list="${deb_list}" \
--label=pkg-list="${pkg_list}" \
"${container}"
buildah config $LABELS "${container}"
# Store the new image (now with labels)
image_id="$( buildah commit "${container}" )"
buildah rm "${container}"
# image tag includes arch; then added to manifest which does not include arch
# Add images to manifest. Individual image tags include arch; manifest does not.
for tag in ${tags} ; do
buildah tag \
"${image_id}" \
Expand Down

0 comments on commit dedefeb

Please sign in to comment.