forgot to login #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# GitHub recommends pinning actions to a commit SHA. | |
# To get a newer version, you will need to update the SHA. | |
# You can also reference a tag or branch, but the action may change without warning. | |
name: Deployment - Docker images | |
on: | |
push: | |
branches: ['release', 'feat/build_apptainer_images'] | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
NAMESPACE: openforcefield | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
image: ['alchemiscale-server', 'alchemiscale-compute'] | |
include: | |
- image: 'alchemiscale-server' | |
dockerfile: 'docker/alchemiscale-server/Dockerfile' | |
- image: 'alchemiscale-compute' | |
dockerfile: 'docker/alchemiscale-compute/Dockerfile' | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Free disk space | |
run: | | |
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true | |
sudo rm -rf \ | |
/usr/share/dotnet /usr/local/lib/android /opt/ghc \ | |
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \ | |
/usr/lib/jvm || true | |
echo "some directories deleted" | |
sudo apt install aptitude -y >/dev/null 2>&1 | |
sudo aptitude purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \ | |
esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \ | |
google-cloud-sdk imagemagick \ | |
libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \ | |
mercurial apt-transport-https mono-complete libmysqlclient \ | |
unixodbc-dev yarn chrpath libssl-dev libxft-dev \ | |
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \ | |
snmp pollinate libpq-dev postgresql-client powershell ruby-full \ | |
sphinxsearch subversion mongodb-org azure-cli microsoft-edge-stable \ | |
-y -f >/dev/null 2>&1 | |
sudo aptitude purge google-cloud-sdk -f -y >/dev/null 2>&1 | |
sudo aptitude purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true | |
sudo apt purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true | |
sudo aptitude purge '~n ^mysql' -f -y >/dev/null 2>&1 | |
sudo aptitude purge '~n ^php' -f -y >/dev/null 2>&1 | |
sudo aptitude purge '~n ^dotnet' -f -y >/dev/null 2>&1 | |
sudo apt-get autoremove -y >/dev/null 2>&1 | |
sudo apt-get autoclean -y >/dev/null 2>&1 | |
echo "some packages purged" | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ matrix.image }} | |
tags: | | |
type=schedule,pattern=nightly,enable=true,priority=1000 | |
type=ref,event=branch,enable=true,priority=600 | |
type=ref,event=tag,enable=true,priority=600 | |
type=ref,event=pr,prefix=pr-,enable=true,priority=600 | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{version}} | |
type=sha | |
${{ github.sha }} | |
- name: Build Docker Image and Push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ${{ matrix.dockerfile }} | |
push: false # change to true after merge, but I don't want to mess anything up while testing | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Setup Apptainer | |
uses: eWaterCycle/setup-apptainer@v2 | |
with: | |
apptainer-version: 1.1.2 | |
- name: Build Apptainer Image | |
run: singularity build ${{ matrix.image }}:$GITHUB_SHA.sif docker-daemon:${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ matrix.image }}:${{ github.sha }} | |
- name: Push Apptainer Image | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io | |
singularity push ${{ matrix.image }}:$GITHUB_SHA.sif oras://${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ matrix.image }}:${{ github.sha }}-apptainer |