Skip to content

Out of memory when building multi-platform images #621

@tk-nguyen

Description

@tk-nguyen

Hello, I'm having some issues building arm64 images with this action. Strangely, the build was fine in some previous jobs.

Expected behaviour

Build should finish normally.

Actual behaviour

Build got killed, probably because of memory issues.

Configuration

Here's the workflow:

on:
  pull_request:
  push:
    paths:
      - "src/**"
      - "Cargo*"
      - "Dockerfile"
    tags:
      - "v*.*.*"

name: Build and push image to GitHub Container Registry

jobs:
  build-and-push:
    name: Build and push image
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          submodules: "recursive"

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Set some variables for the image
        run: |
          echo "IMAGE_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
          echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
      - name: Build and push the image
        uses: docker/build-push-action@v3
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          cache-from: |
            type=gha
          cache-to: |
            type=gha
          tags: |
            ghcr.io/${{ env.IMAGE_NAME }}:latest
            ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }}

Logs

2022-05-21T15:25:01.4848764Z #18 [linux/arm64 build 4/4] RUN cargo build --release
2022-05-21T15:25:53.8174393Z #18 1988.6    Compiling dtoa v0.4.8
2022-05-21T15:26:00.8748428Z #18 1995.6    Compiling rustc-demangle v0.1.21
2022-05-21T15:26:40.5438038Z #18 2035.3    Compiling crc32fast v1.3.2
2022-05-21T15:26:47.6095100Z #18 2042.4    Compiling rustls v0.20.6

<lots of logs.......>

2022-05-21T16:33:55.5166199Z #18 6070.3    Compiling color-eyre v0.5.11
2022-05-21T16:34:15.0620335Z #18 6089.9    Compiling reqwest v0.11.10
2022-05-21T16:34:52.0416710Z #18 6126.9    Compiling reqwest v0.9.24
2022-05-21T16:46:00.6039013Z #18 6795.4    Compiling ddg v0.5.0 (https://github.com/tk-nguyen/ddg#caf14098)
2022-05-21T16:47:39.2254588Z #18 6894.1    Compiling scraper v0.13.0
2022-05-21T16:53:17.2139199Z #18 7232.0 Killed
2022-05-21T16:53:17.3063516Z #18 ERROR: process "/bin/sh -c cargo build --release" did not complete successfully: exit code: 137
2022-05-21T16:53:17.3822671Z ------
2022-05-21T16:53:17.3823888Z  > [linux/arm64 build 4/4] RUN cargo build --release:
2022-05-21T16:53:17.3824683Z  tracing-error v0.1.2
2022-05-21T16:53:17.3825783Z   Compiling color-spantrace v0.1.6
2022-05-21T16:53:17.3826179Z   Compiling hyper-rustls v0.23.0
2022-05-21T16:53:17.3826561Z #18 6058.7    Compiling hyper-rustls v0.17.1
2022-05-21T16:53:17.3826928Z   Compiling color-eyre v0.5.11
2022-05-21T16:53:17.3827185Z #18 6089.9    Compiling reqwest v0.11.10
2022-05-21T16:53:17.3827454Z #18 6126.9    Compiling reqwest v0.9.24
2022-05-21T16:53:17.3828217Z   Compiling ddg v0.5.0 (https://github.com/tk-nguyen/ddg#caf14098)
2022-05-21T16:53:17.3828546Z #18 6894.1    Compiling scraper v0.13.0
2022-05-21T16:53:17.3828790Z #18 7232.0 Killed

I also tried to build locally using buildx, and arm64 builds also got killed because the host machine ran out of memory. I saw people were getting similar errors on docker/buildx#292 and docker/buildx#359. There is a proposal here but there has been no updates since. Is there any other way I can limit the memory of the builders?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions