feat: Dockerfile for release and test (#2) #3
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: docker | |
| on: | |
| push: | |
| branches: | |
| - master | |
| env: | |
| DOCKERHUB_USERNAME: inconetwork | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| strategy: | |
| matrix: | |
| include: | |
| - path: "Dockerfile.release" | |
| name: "gramine" | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Nix | |
| uses: ./.github/actions/use-nix | |
| with: | |
| github-access-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to Docker Hub | |
| env: | |
| DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| run: | | |
| nix develop -c bash -lc ' | |
| echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | |
| ' | |
| - name: Set up Docker Buildx | |
| run: | | |
| nix develop -c bash -lc ' | |
| docker buildx create --name ci-builder --driver docker-container --use || docker buildx use ci-builder | |
| docker buildx inspect --bootstrap | |
| ' | |
| - name: Git Describe | |
| id: git_desc | |
| run: nix develop -c bash -lc 'echo "tagish=$(git describe --tags --always)" | tee $GITHUB_OUTPUT' | |
| - name: Build and push | |
| env: | |
| DOCKERFILE: ${{ matrix.path }} | |
| IMAGE_TAG: inconetwork/${{ matrix.name }}:${{ steps.git_desc.outputs.tagish }} | |
| CACHE_SCOPE: ${{ matrix.name }} | |
| run: | | |
| nix develop -c bash -lc ' | |
| docker buildx build \ | |
| --file "$DOCKERFILE" \ | |
| --tag "$IMAGE_TAG" \ | |
| --cache-from "type=gha,scope=$CACHE_SCOPE" \ | |
| --cache-to "type=gha,mode=max,scope=$CACHE_SCOPE" \ | |
| --push \ | |
| . | |
| ' |