Search code examples
google-cloud-platformgoogle-cloud-rungoogle-cloud-build

Using Docker heredoc with Google Cloud


It's been a while since Docker introduced the ability to use heredoc in the RUN command, and I use it quite often.

However, when I tried to use it with Cloud Run, it seems that this feature is not supported, or do I need to do something to enable it?

Example:

FROM ubuntu:jammy

RUN <<EOF
apt-get update
apt-get upgrade -y
apt-get install -y build-essential cmake git python3 python3-pip wget zip
pip install conan
conan profile detect
EOF

I get the error:

Error response from daemon: dockerfile parse error line 13: unknown instruction: APT-GET


Solution

  • Unfortunately, we can't expect much from Google, so I chose to build the image in GitHub Actions, push it to the registry, and then point the Run to the new image.

    - name: Build and push
      uses: docker/build-push-action@v5
      with:
        context: .
        push: true
        tags: ${{ secrets.REGISTRY }}/${{ secrets.SERVICE_NAME }}:latest
        cache-from: type=gha
        cache-to: type=gha,mode=max