|
| 1 | +name: Build and Push Images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + paths: |
| 8 | + - 'workflows/**' |
| 9 | + - 'crates/**' |
| 10 | + - 'bin/**' |
| 11 | + - 'Cargo.toml' |
| 12 | + merge_group: |
| 13 | + |
| 14 | +env: |
| 15 | + ECR_REPOSITORY: public.ecr.aws/succinct-labs/prover |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-amd64: |
| 19 | + runs-on: |
| 20 | + [ |
| 21 | + 'runs-on', |
| 22 | + 'runner=32cpu-linux-x64', |
| 23 | + 'run-id=${{ github.run_id }}', |
| 24 | + 'hdd=41', |
| 25 | + 'spot=false', |
| 26 | + 'tag=gpu', |
| 27 | + 'disk=large', |
| 28 | + ] |
| 29 | + steps: |
| 30 | + - name: Add SHORT_SHA env property with commit short sha |
| 31 | + run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV |
| 32 | + |
| 33 | + # https://github.com/orgs/community/discussions/25678 |
| 34 | + - name: Delete huge unnecessary tools folder |
| 35 | + run: | |
| 36 | + df -h |
| 37 | + sudo rm -rf /opt/hostedtoolcache |
| 38 | + sudo rm -rf /usr/share/dotnet |
| 39 | + sudo rm -rf /usr/local/share/boost |
| 40 | + sudo rm -rf "$AGENT_TOOLSDIRECTORY" |
| 41 | + df -h |
| 42 | +
|
| 43 | + - name: Checkout repo |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + submodules: true |
| 47 | + |
| 48 | + - name: Setup CI |
| 49 | + uses: ./.github/actions/setup |
| 50 | + |
| 51 | + - name: Configure AWS credentials |
| 52 | + uses: 'aws-actions/configure-aws-credentials@v1' |
| 53 | + with: |
| 54 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 55 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 56 | + aws-region: ${{ secrets.AWS_REGION }} |
| 57 | + |
| 58 | + - name: Set up Docker |
| 59 | + uses: docker/setup-buildx-action@v3 |
| 60 | + with: |
| 61 | + platforms: linux/amd64,linux/arm64 |
| 62 | + |
| 63 | + - name: Set up NVIDIA Container Toolkit |
| 64 | + run: | |
| 65 | + distribution=$(. /etc/os-release;echo $ID$VERSION_ID) |
| 66 | + curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - |
| 67 | + curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list |
| 68 | + sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit |
| 69 | + sudo systemctl restart docker |
| 70 | +
|
| 71 | + - name: Login to Amazon ECR Public |
| 72 | + uses: aws-actions/amazon-ecr-login@v2 |
| 73 | + with: |
| 74 | + registry-type: public |
| 75 | + |
| 76 | + - name: Build and Push AMD64 GPU image |
| 77 | + uses: docker/build-push-action@v5 |
| 78 | + with: |
| 79 | + context: . |
| 80 | + file: ./Dockerfile.gpu |
| 81 | + platforms: linux/amd64 |
| 82 | + push: true |
| 83 | + tags: ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-amd64 |
| 84 | + build-args: | |
| 85 | + PRIVATE_PULL_TOKEN=${{ secrets.PRIVATE_PULL_TOKEN }} |
| 86 | + cache-from: type=gha |
| 87 | + cache-to: type=gha,mode=max |
| 88 | + |
| 89 | + - name: Build and Push AMD64 CPU image |
| 90 | + uses: docker/build-push-action@v5 |
| 91 | + with: |
| 92 | + context: . |
| 93 | + file: ./Dockerfile.cpu |
| 94 | + platforms: linux/amd64 |
| 95 | + push: true |
| 96 | + tags: ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-amd64 |
| 97 | + build-args: | |
| 98 | + PRIVATE_PULL_TOKEN=${{ secrets.PRIVATE_PULL_TOKEN }} |
| 99 | + cache-from: type=gha |
| 100 | + cache-to: type=gha,mode=max |
| 101 | + |
| 102 | + build-arm64: |
| 103 | + runs-on: |
| 104 | + [ |
| 105 | + 'runs-on', |
| 106 | + 'runner=32cpu-linux-arm64', |
| 107 | + 'run-id=${{ github.run_id }}', |
| 108 | + 'hdd=41', |
| 109 | + 'spot=false', |
| 110 | + 'tag=gpu', |
| 111 | + 'disk=large', |
| 112 | + ] |
| 113 | + steps: |
| 114 | + - name: Add SHORT_SHA env property with commit short sha |
| 115 | + run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV |
| 116 | + |
| 117 | + - name: Delete huge unnecessary tools folder |
| 118 | + run: | |
| 119 | + df -h |
| 120 | + sudo rm -rf /opt/hostedtoolcache |
| 121 | + sudo rm -rf /usr/share/dotnet |
| 122 | + sudo rm -rf /usr/local/share/boost |
| 123 | + sudo rm -rf "$AGENT_TOOLSDIRECTORY" |
| 124 | + df -h |
| 125 | +
|
| 126 | + - name: Checkout repo |
| 127 | + uses: actions/checkout@v4 |
| 128 | + with: |
| 129 | + submodules: true |
| 130 | + |
| 131 | + - name: Setup CI |
| 132 | + uses: ./.github/actions/setup |
| 133 | + |
| 134 | + - name: Configure AWS credentials |
| 135 | + uses: 'aws-actions/configure-aws-credentials@v1' |
| 136 | + with: |
| 137 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 138 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 139 | + aws-region: ${{ secrets.AWS_REGION }} |
| 140 | + |
| 141 | + - name: Set up Docker |
| 142 | + uses: docker/setup-buildx-action@v3 |
| 143 | + |
| 144 | + - name: Set up NVIDIA Container Toolkit |
| 145 | + run: | |
| 146 | + distribution=$(. /etc/os-release;echo $ID$VERSION_ID) |
| 147 | + curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - |
| 148 | + curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list |
| 149 | + sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit |
| 150 | + sudo systemctl restart docker |
| 151 | +
|
| 152 | + - name: Login to Amazon ECR Public |
| 153 | + uses: aws-actions/amazon-ecr-login@v2 |
| 154 | + with: |
| 155 | + registry-type: public |
| 156 | + |
| 157 | + - name: Build and Push ARM64 GPU image |
| 158 | + uses: docker/build-push-action@v5 |
| 159 | + with: |
| 160 | + context: . |
| 161 | + file: ./Dockerfile.gpu |
| 162 | + platforms: linux/arm64 |
| 163 | + push: true |
| 164 | + tags: ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-arm64 |
| 165 | + build-args: | |
| 166 | + PRIVATE_PULL_TOKEN=${{ secrets.PRIVATE_PULL_TOKEN }} |
| 167 | + cache-from: type=gha |
| 168 | + cache-to: type=gha,mode=max |
| 169 | + |
| 170 | + - name: Build and Push ARM64 CPU image |
| 171 | + uses: docker/build-push-action@v5 |
| 172 | + with: |
| 173 | + context: . |
| 174 | + file: ./Dockerfile.cpu |
| 175 | + platforms: linux/arm64 |
| 176 | + push: true |
| 177 | + tags: ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-arm64 |
| 178 | + build-args: | |
| 179 | + PRIVATE_PULL_TOKEN=${{ secrets.PRIVATE_PULL_TOKEN }} |
| 180 | + cache-from: type=gha |
| 181 | + cache-to: type=gha,mode=max |
| 182 | + |
| 183 | + create-manifest: |
| 184 | + needs: [build-amd64, build-arm64] |
| 185 | + runs-on: ubuntu-latest |
| 186 | + steps: |
| 187 | + - name: Add SHORT_SHA env property with commit short sha |
| 188 | + run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV |
| 189 | + |
| 190 | + - name: Configure AWS credentials |
| 191 | + uses: 'aws-actions/configure-aws-credentials@v1' |
| 192 | + with: |
| 193 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 194 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 195 | + aws-region: ${{ secrets.AWS_REGION }} |
| 196 | + |
| 197 | + - name: Login to Amazon ECR Public |
| 198 | + uses: aws-actions/amazon-ecr-login@v2 |
| 199 | + with: |
| 200 | + registry-type: public |
| 201 | + |
| 202 | + - name: Create and push GPU manifest |
| 203 | + run: | |
| 204 | + docker buildx imagetools create -t ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }} \ |
| 205 | + ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-amd64 \ |
| 206 | + ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-arm64 |
| 207 | + docker buildx imagetools create -t ${{ env.ECR_REPOSITORY }}-gpu:latest \ |
| 208 | + ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-amd64 \ |
| 209 | + ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-arm64 |
| 210 | +
|
| 211 | + - name: Create and push CPU manifest |
| 212 | + run: | |
| 213 | + docker buildx imagetools create -t ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }} \ |
| 214 | + ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-amd64 \ |
| 215 | + ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-arm64 |
| 216 | + docker buildx imagetools create -t ${{ env.ECR_REPOSITORY }}-cpu:latest \ |
| 217 | + ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-amd64 \ |
| 218 | + ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-arm64 |
0 commit comments