update readme for containers #7
This file contains hidden or 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
| name: Build Docker and Singularity Images | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| release: | |
| types: [published] | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| build-docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Add this step to ensure the image name is lowercase | |
| - name: Set lower case owner name | |
| run: | | |
| echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v4 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Test Docker Image | |
| # Make sure default entrypoint won't override pytest command by running with bash if needed | |
| # Or running pytest via the command correctly. Adjust according to Dockerfile Entrypoint. | |
| run: | | |
| docker run --rm --entrypoint="" ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main pytest tests/test_cli_interface.py | |
| build-singularity: | |
| needs: build-docker | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Add this step to ensure the image name is lowercase here as well | |
| - name: Set lower case owner name | |
| run: | | |
| echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | |
| - name: Setup Apptainer/Singularity | |
| uses: eWaterCycle/setup-apptainer@v2 | |
| with: | |
| apptainer-version: 1.2.2 | |
| - name: Build Singularity Image | |
| # Note: We pull the exact tag generated in the Docker build step | |
| run: | | |
| IMAGE_URL="docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main" | |
| apptainer build micaflow.sif $IMAGE_URL | |
| - name: Test Singularity Image | |
| run: | | |
| apptainer exec micaflow.sif pytest tests/test_cli_interface.py | |
| - name: Upload Singularity Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: micaflow-singularity | |
| path: micaflow.sif |