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

chore: add set -e for RUN heredoc instruction #280

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

endersonmaia
Copy link
Contributor

@endersonmaia endersonmaia commented Jan 24, 2024

When replacing RUN apt update && apt install ... we were making use of &&, that ensures that the following command will only execute if the previous one succeeds. When using the RUN <<EOF format, we lose this and can have some surprises uring the docker build process. It's common for a command inside an RUN heredoc type to have a filing process but that whole instruction pass as a success in the build, and the result will only be noticed on the runtime image.

Adding set -e will ensure that if any command fails, the whole instruction will fail.

See: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html

@endersonmaia endersonmaia requested a review from a team January 24, 2024 16:22
@endersonmaia endersonmaia added the no changelog PRs that don't require changes in changelog label Jan 24, 2024
When replacing RUN apt update && apt install ... we were making use of
&&, that ensures that the following command will only execute if the
previous one succeeds. When using the RUN <<EOF format, we lose this and
can have some susprises during the docker build process. It's common for
a command inside an RUN heredoc type to have a filing process but that
whole instruction pass as a success in the build, and the result will
only be noticed on the runtime image.

Adding set -e will ensure that if any command fails, the whole
instruction will fail.
@gligneul
Copy link
Contributor

Nice catch

@gligneul gligneul merged commit 419a1ea into main Jan 24, 2024
6 checks passed
@gligneul gligneul deleted the chore/add-set-e-heredoc-run branch January 24, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog PRs that don't require changes in changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants