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
I managed to build an image using heredocs
with Google Cloud Builds
and it runs properly on Google Cloud Run
.
Dockerfile
I added:#syntax=docker/dockerfile:1.4
heredocs
were introduced in this version:
https://docs.docker.com/build/dockerfile/release-notes/#140
cloudbuild.yaml
I used the command docker buildx build ...
to use docker toolkit.steps:
- id: "Build Docker Image: -> "
name: "gcr.io/cloud-builders/docker"
args: ["buildx", "build", "-t", "${_TAG}", "."]
# ...
I tried it on my machine, but I have also faced the same error as yours when deployed to cloud run.. To answer your specific question
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?
From my above repro I believe that heredoc
is still not supported by cloud run
. And I don't think there is something else to be enabled to get it to work. As a work around you may try below script as suggested here
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y ...
Although work around is there you can still consider raising a feature request in GCP public issue tracker with your use case scenario.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With