Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command parameter and support arrays for command and shell #68

Merged
merged 4 commits into from
Sep 30, 2018

Conversation

lox
Copy link
Contributor

@lox lox commented Sep 24, 2018

It dawned on @toolmantim and I that a good solution to the question of whether this plugin and docker-compose should default to a shell is the following:

  • If a command is provided via the step-level command, assume a shell, as we tend to do things like yarn install && yarn start in examples:
steps:
  - command: yarn install && yarn run test
    plugins:
      docker#v1.4.0:
        image: "node:7"
        workdir: /app

The above will translate to /bin/sh -e -c 'yarn install && yarn run test' in the container. This will also support multiple line commands.

  • If no step level command is provided, no shell is used. If you want control over exactly what command is passed to docker (e.g how the command is split into arguments), you can use the new plugin level command this PR introduces:
steps:
  - plugins:
      docker#v1.4.0:
        image: "koalaman/shellcheck"
        command: ["--exclude=SC2207", "/app/script.sh"]
        workdir: /app

This avoids us having to do any shell word parsing, which is horrible for complexity and security.

The new array syntax is also applied to entrypoint and shell:

steps:
  - plugins:
       docker#v1.4.0:
         image: "alpine"
         command: ["echo", "hello", "world"]
         shell: ["/bin/sh", "-c"]

@lox lox changed the title Add a command parameter and support lists for command, entrypoint and shell Add a command parameter and support arrays for command and shell Sep 27, 2018
@lox
Copy link
Contributor Author

lox commented Sep 27, 2018

This is ready to go if you get a chance to review it @toolmantim or @matthewd

Copy link
Contributor

@toolmantim toolmantim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants