diff --git a/.github/workflows/docker.sh b/.github/workflows/docker.sh index 6065c6faf9..e6252295f9 100755 --- a/.github/workflows/docker.sh +++ b/.github/workflows/docker.sh @@ -2,7 +2,7 @@ set -ex -image="ghcr.io/$GITHUB_REPOSITORY" +image="$ECR_REGISTRY/$ECR_REPOSITORY" tag=$(git tag --points-at HEAD) if [ -z "$tag" ]; then @@ -10,7 +10,19 @@ if [ -z "$tag" ]; then fi echo $image:$tag -docker buildx create --name mybuilder --use || echo 'skip' +docker buildx create --name mybuilder --use --bootstrap || echo 'skip' docker buildx inspect --bootstrap -docker buildx build --platform linux/amd64,linux/arm64 -t $image:$tag --push . + +dockerfile="./Dockerfile" +docker buildx build \ + --progress plain \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --cache-from type=registry,ref=${image}:cache \ + --cache-to type=registry,image-manifest=true,oci-mediatypes=true,ref=${image}:cache,mode=max \ + --compress \ + --push \ + --platform linux/amd64,linux/arm64 \ + -t "$image:$tag" \ + -f "${dockerfile}" . docker buildx imagetools inspect $image:$tag +echo "image=$image:$tag" >> $GITHUB_OUTPUT diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cdd8880518..9c570c949b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,10 +14,22 @@ jobs: with: fetch-depth: 0 - - name: Login to ghcr.io - env: - PAT: ${{ secrets.GH_TOKEN }} - run: printf "$PAT" | docker login --username _ --password-stdin ghcr.io + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Add exec permission to docker.sh + run: chmod +x ./.github/workflows/docker.sh - name: Build and push Docker images + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: glitchd-ecr-repository-${{ secrets.STAGE }}-geth run: ./.github/workflows/docker.sh