Giter Site home page Giter Site logo

Comments (5)

binkley avatar binkley commented on June 14, 2024

I'm not sure this is a multiline issue. I was trying YAML multiline options from: https://yaml-multiline.info/

When I tried using a single-line, single-quoted string, I still had the same complaint:

  run:
    run:
      container: build-env
      command: './gradlew assemble && java -jar build/libs/docker-java11-0.0.1-SNAPSHOT.jar'

from batect.

binkley avatar binkley commented on June 14, 2024

Ah, I get it now. Trying echo $0 $SHELL $- reveals that this is not passed to /bin/sh as I had expected. And recognizing the batect.yml file is for Docker Compose, I checked the docs on command. Those docs are not explicit, but I infer that the value of the command line in YAML is passed to the exec() call, so does not invoke /bin/sh.

The complaint about "task" comes from Gradle, not Batect.

This works, if annoying in it's verbosity:

  run:
    run:
      container: build-env
      command: '/bin/sh -c "./gradlew assemble && java -jar build/libs/docker-java11-0.0.1-SNAPSHOT.jar"'

A little more nicely:

  run:
    run:
      container: build-env
      command: >-
        /bin/sh -c './gradlew assemble
        && java -jar build/libs/docker-java11-0.0.1-SNAPSHOT.jar'

(Note: Do not indent further at "&&"; this changes the parsing somehow.)

from batect.

binkley avatar binkley commented on June 14, 2024

@charleskorn I'm ok with closing this. Contra, it could be a documentation request. Since Docker Compose itself doesn't explain this well, I'm uncertain if Batect should, though it is a gotcha for the unaware.

from batect.

charleskorn avatar charleskorn commented on June 14, 2024

Thanks for the feedback @binkley.

What you're seeing is the behaviour of ENTRYPOINT and CMD from Docker (see https://docs.docker.com/engine/reference/builder/#cmd) - I'm guessing the image you're using doesn't have an entrypoint set, and so the command you give is executed directly, rather than being interpreted by a shell (which would handle the && in the way you expect).

If you wanted to remove the need to use /bin/sh -c '...', you could set your entrypoint (in your Dockerfile) to execute sh. For example, add this to your Dockerfile:

ENTRYPOINT ["/bin/sh", "-c"]

(There's more explanation of this in the docs I linked to above.)

I think it's worthwhile adding some docs around this, as it's a common point of confusion - so thanks for the suggestion.

As a further aside, batect does not use Docker Compose internally - while similar, they are independent.

from batect.

charleskorn avatar charleskorn commented on June 14, 2024

I've updated the docs with a note about this - thanks again for the feedback @binkley!

from batect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.