Skip to content

Full rocker & bioc build #88

Full rocker & bioc build

Full rocker & bioc build #88

# This is a basic workflow to help you get started with Actions
name: Full rocker & bioc build
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
inputs:
rver:
default: "devel"
biocver:
default: "3.20"
outname:
default: "bioconductor_docker"
schedule:
- cron: '0 18 * * 5'
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Push patch bump
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 50
shell: bash
command: |
set -x
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config user.name github-actions
git config user.email [email protected]
git pull origin main || git reset --hard origin/main
sed -r -i 's/(^ARG BIOCONDUCTOR_PATCH=)([0-9]+)$/echo "\1$((\2+1))"/ge' Dockerfile
git add Dockerfile
git commit -m "Bump BIOCONDUCTOR_PATCH"
git push
build:
outputs:
registryuser: ${{ steps.defs.outputs.registryuser }}
outname: ${{ steps.defs.outputs.outname }}
rver: ${{ steps.defs.outputs.rver }}
strategy:
matrix:
arch: [amd64, arm64]
runs-on: ubuntu-latest
needs: bump
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Free root space
uses: almahmoud/free-root-space@main
with:
verbose: true
- name: Set defaults for schedule
id: defs
run: |
echo outname=$(echo ${{ github.event.inputs.outname || 'bioconductor_docker' }}) >> $GITHUB_OUTPUT
echo rver=$(echo ${{ github.event.inputs.rver || 'devel' }}) >> $GITHUB_OUTPUT
echo biocver=$(echo ${{ github.event.inputs.biocver || '3.20' }}) >> $GITHUB_OUTPUT
echo registryuser=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}') >> $GITHUB_OUTPUT
echo rockerintermediateprefix=$(echo "ghcr.io/${{ github.repository_owner }}/rocker" | awk '{print tolower($0)}') >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
if: matrix.arch == 'arm64'
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata for container image
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ steps.defs.outputs.registryuser }}/${{ steps.defs.outputs.outname }}
tags: |
type=raw,value=${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
- name: Set comma-separated list with all repository names
id: images
run: |
IMG=${{ steps.meta.outputs.tags }}
REPOLIST="docker.io/$IMG,ghcr.io/$IMG"
echo ghcr=$(echo "ghcr.io/$IMG") >> $GITHUB_OUTPUT
SUB="_docker"
# Also add alternative without _docker when in name
echo list=$(if [[ $REPOLIST == *$SUB* ]]; then echo "$REPOLIST,$(echo $REPOLIST | sed 's/_docker//g')"; else echo $REPOLIST; fi) >> $GITHUB_OUTPUT
bash .github/scripts/rocker_prep.sh "${{ steps.defs.outputs.rver }}" "${{ steps.defs.outputs.biocver }}" "${{ steps.defs.outputs.rockerintermediateprefix }}" "${{ matrix.arch }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/${{ matrix.arch }}
- name: Build and load r-ver
uses: docker/build-push-action@v3
with:
file: rocker-versioned2/dockerfiles/r-ver_${{ steps.defs.outputs.rver }}.Dockerfile
context: rocker-versioned2
push: true
tags: ${{ steps.defs.outputs.rockerintermediateprefix }}-r-ver:${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
- name: Build and load rstudio
uses: docker/build-push-action@v3
with:
file: rocker-versioned2/dockerfiles/rstudio_${{ steps.defs.outputs.rver }}.Dockerfile
context: rocker-versioned2
push: true
tags: ${{ steps.defs.outputs.rockerintermediateprefix }}-rstudio:${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
- name: Build and push container image to all repos both arm64 and amd64
uses: docker/build-push-action@v3
with:
build-args: |
BASE_IMAGE=${{ steps.defs.outputs.rockerintermediateprefix }}-rstudio
arm64_tag=${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
amd64_tag=${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
BIOCONDUCTOR_VERSION=${{ steps.defs.outputs.biocver }}
file: Dockerfile
context: .
push: true
tags: ${{ steps.images.outputs.list }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/${{ matrix.arch }}
test-built-containers:
strategy:
matrix:
arch: [arm64, amd64]
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: build
steps:
- name: Get image name
id: image
run: |
IMG=$(echo "${{needs.build.outputs.registryuser}}/${{ needs.build.outputs.outname }}:${{ needs.build.outputs.rver }}-${{ matrix.arch }}")
echo name=$IMG >> $GITHUB_OUTPUT
cat << EOF > test.Dockerfile
FROM $IMG as test
USER root
RUN mkdir -p /tmp/bioc_test && \
apt list --installed | tee /tmp/bioc_test/aptlist && \
Rscript -e "BiocManager::install(c('SummarizedExperiment','usethis','data.table','igraph','GEOquery'))" 2>&1 | tee /tmp/bioc_test/packages_install && \
Rscript -e "BiocManager::install('gert'); require('gert')" 2>&1 | tee /tmp/bioc_test/gert_install
FROM scratch as export
COPY --from=test /tmp/bioc_test /tmp
EOF
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
if: matrix.arch == 'arm64'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/${{ matrix.arch }}
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Test via build
id: dockerbuild
uses: docker/build-push-action@v4
with:
file: test.Dockerfile
context: .
push: false
load: false
outputs: type=tar,dest=/tmp/image.tar
tags: ${{ steps.image.outputs.name }}
- run: |
mkdir -p /tmp/contents
cd /tmp/contents
tar -xvf /tmp/image.tar
sudo ls tmp/* | xargs -i bash -c "echo 'cat {}' && cat {}"