E

Heredoc Syntax Support Inquiry

Summary

The user is asking if the earthly tool supports heredoc syntax, as they couldn't find relevant information in the documentation. They mention that heredoc syntax is available in BuildKit since version 1.6.0. The user provides a code snippet that fails with multiple syntax errors, specifically pointing out issues related to the lexer and token recognition in their Earthfile.

Status
resolved
Tags
  • Heredoc
  • Documentation
  • Syntax Support
  • earthly
  • 1.6.0
  • Syntax Error
  • Developer
  • Question
  • Developer Help
Source
#earthly
    e

    exographicskip44

    11/13/2024

    This fails with a bunch of syntax errors:

        FROM +build-base
        ARG TARGETPLATFORM
        ARG PROFILE
        COPY +deps/recipe.json recipe.json
    
        RUN <<EOF
            #!/usr/bin/env sh
            if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
                TARGET_ARCH="x86_64-unknown-linux-musl"
            else
                TARGET_ARCH="aarch64-unknown-linux-musl"
            fi
            echo "Cooking dependencies for $TARGET_ARCH with profile ${PROFILE}"
            cargo chef cook --recipe-path recipe.json --profile ${PROFILE} --zigbuild --target $TARGET_ARCH
        EOF```
    like
    ```Error: resolve build context for target +cook: lexer error: Earthfile
    syntax error: line 50:8: token recognition error at: 'if '
    syntax error: line 50:11: token recognition error at: '['
    syntax error: line 50:13: token recognition error at: '"'
    syntax error: line 50:14: token recognition error at: '$'```
    
    e

    exographicskip44

    11/12/2024

    Does earthly support heredoc syntax? Not seeing anything in the docs. It's available in <https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#here-documents|buildkit as of 1.6.0>