Skip to content

Commit

Permalink
Merge branch 'template_docker' into buildcache
Browse files Browse the repository at this point in the history
  • Loading branch information
kkrizka committed Jan 1, 2025
2 parents c90ff05 + 9b4042c commit 4b6e9e3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 168 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/image-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build and Publish Docker Image

on:
workflow_call:
inputs:
image:
required: true
type: string

env:
REGISTRY: ghcr.io

jobs:
build-image:
runs-on: ubuntu-latest
strategy:
matrix:
os: [{dir: AlmaLinux9,suffix: alma9}]
env:
IMAGE_NAME: mucoll-${{inputs.image}}
steps:
- name: Free Disk Space (Ubuntu)
uses: endersonmenezes/free-disk-space@v2
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_tool_cache: true
remove_swap: true
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
remove_packages_one_command: true
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/share/glade* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell"
testing: false
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Make owner name lowercase
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{env.OWNER_LC}}/mucoll-dummy
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./${{matrix.os.dir}}
file: ./${{matrix.os.dir}}/Dockerfile-${{inputs.image}}
push: true
build-args: |
VERSION=${{ steps.meta.outputs.version }}
REPOSITORY=${{ env.REGISTRY }}/${{env.OWNER_LC}}
GITHUB_REPOSITORY=${{ github.repository }}
MUCOLL_SHA=${{ github.sha }}
SPACK_BUILDCACHE=oci://ghcr.io/${{ github.repository_owner }}/spack-buildcache
tags: ${{ env.REGISTRY }}/${{env.OWNER_LC}}/${{ env.IMAGE_NAME}}:${{steps.meta.outputs.version}}-${{matrix.os.suffix}}
labels: ${{ steps.meta.outputs.labels }}
21 changes: 21 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build and Publish Docker Image
on: push

env:
REGISTRY: ghcr.io

jobs:
build-spack:
uses: ./.github/workflows/image-template.yaml
with:
image: spack
build-minimal:
needs: build-spack
uses: ./.github/workflows/image-template.yaml
with:
image: minimal
build-sim:
needs: build-minimal
uses: ./.github/workflows/image-template.yaml
with:
image: sim
165 changes: 0 additions & 165 deletions .github/workflows/image.yml

This file was deleted.

4 changes: 1 addition & 3 deletions AlmaLinux9/Dockerfile-spack
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ ARG SPACK_BUILDCACHE
RUN source /opt/setup_spack.sh && \
spack compiler find && \
if [ -n "${SPACK_BUILDCACHE}" ]; then \
for buildcache in ${SPACK_BUILDCACHE//:/ }; do \
spack mirror add --unsigned local-buildcache "${buildcache}"; \
done \
spack mirror add --unsigned local-buildcache "${SPACK_BUILDCACHE}"; \
fi

0 comments on commit 4b6e9e3

Please sign in to comment.