Modernize Dockerfile with multi-stage build #103
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 | |
| on: [push] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Free up disk space | |
| run: | | |
| echo "Disk space before cleanup:" | |
| df -h | |
| # Remove unnecessary tools and packages (frees ~15-20GB) | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf "/usr/local/share/boost" | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /usr/local/.ghcup | |
| sudo rm -rf /usr/share/swift | |
| # Clean apt cache | |
| sudo apt-get clean | |
| # Clean Docker system | |
| docker system prune -af --volumes | |
| echo "Disk space after cleanup:" | |
| df -h | |
| - name: Set git branch and tag variables | |
| run: | | |
| echo "BRANCH=$(git branch --show-current)" >> $GITHUB_ENV | |
| if [ "$(git branch --show-current)" == "main" ]; then | |
| echo "TAG=$(git describe --tags)" >> $GITHUB_ENV | |
| else | |
| echo "TAG=$(git branch --show-current)" >> $GITHUB_ENV | |
| fi | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Registry | |
| run: docker login quay.io -u ${{ secrets.QUAY_USERNAME }} --password ${{ secrets.QUAY_PASSWORD }} | |
| - name: Build the Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| load: true | |
| tags: quay.io/matsengrp/linearham:${{ env.TAG }} | |
| no-cache: true | |
| - name: Run tests in the Docker image | |
| run: docker run quay.io/matsengrp/linearham:${{ env.TAG }} sh -c "/linearham/_build/test/test" | |
| - name: Run fast integration test in the Docker image | |
| run: docker run --rm quay.io/matsengrp/linearham:${{ env.TAG }} sh -c "/linearham/test-fast.sh && /linearham/clean.sh" | |
| #- name: publish to Registry | |
| # run: docker push quay.io/matsengrp/linearham:${{ env.TAG }} | |
| - name: Build documentation | |
| if: github.ref == 'refs/heads/main' | |
| run: docker run --rm -v $(pwd):/data nakatt/doxygen:1.8.17 Doxyfile | |
| - name: Deploy to GitHub Pages | |
| if: github.ref == 'refs/heads/main' | |
| uses: JamesIves/[email protected] | |
| with: | |
| ACCESS_TOKEN: ${{ secrets.GH_PAGES_PERSONAL_ACCESS_TOKEN }} | |
| BRANCH: gh-pages | |
| FOLDER: html | |
| - name: Slack Notification | |
| uses: homoluctus/slatify@master | |
| if: always() | |
| with: | |
| type: ${{ job.status }} | |
| job_name: 'Linearham Build' | |
| url: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK}} |