-
Notifications
You must be signed in to change notification settings - Fork 23
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: improve the run_macaron.sh script #521
Conversation
Signed-off-by: Nathan Nguyen <[email protected]>
Signed-off-by: Nathan Nguyen <[email protected]>
Signed-off-by: Nathan Nguyen <[email protected]>
Signed-off-by: Nathan Nguyen <[email protected]>
Signed-off-by: Nathan Nguyen <[email protected]>
…tory exists Signed-off-by: Nathan Nguyen <[email protected]>
Signed-off-by: Nathan Nguyen <[email protected]>
1bca05d
to
d1f6341
Compare
Signed-off-by: Nathan Nguyen <[email protected]>
@@ -373,10 +349,11 @@ proxy_var_names=( | |||
"NO_PROXY" | |||
"MAVEN_OPTS" | |||
"GRADLE_OPTS" | |||
"JAVA_OPTS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason we pass MAVEN_OPTS
and GRADLE_OPTS
is to download mvnw
and gradlew
when proxy is set. With JAVA_OPTS
we will pass a lot more options, potentially interfering with the JVM process. Have you encountered a case where JAVA_OPTS
is absolutely necessary and the other environment variables cannot be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted in d47f254.
Signed-off-by: Nathan Nguyen <[email protected]>
We use |
Signed-off-by: Nathan Nguyen <[email protected]>
RST doc has been adjusted in 57e3c16. |
The latest changes to the RST doc files look good to me. My approval still holds. |
Signed-off-by: Nathan Nguyen <[email protected]>
This pull request makes a number of improvements to our current
run_macaron.sh
script.This is to prepare for another pull request, #512, which adds support for Podman as an alternative container engine to run the Macaron image.
Set bash "strict" flags
Commit: 95cb003
The following bash built-in flags are added to the script. These flags effectively help make the script less error-prone.
set -e
: exit immediately if a command fails (with non-zero return code), or if a function returns non-zero.set -u
: treat unset variables and parameters as errors when performing parameter expansion.Note: In case a variable
${VAR}
is unset but we still need to expand, we can use the syntax${VAR:-}
to expand it to an empty string (bash documentation).set -o pipefail
: set the return value of a pipeline to the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully.Reference: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html.
Simplify passing environment variables into the container
Commit: b4d49f0
During
docker run
, we can pass environment variables into the container as follows:$ docker run [...] -e "http_proxy=${http_proxy}" [...]
In cases where we want the container to "inherit" the environment variables on the host, we do not need to explicitly specify the value, i.e., doing this should be enough:
Passing the environment variables into the container in this implicit manner is also very useful when we want to use the
set -x
flag of bash for debugging purposes but do not want secret values to be logged out as plain text.Inherit the
JAVA_OPTS
environment variable into the containerCommit: d1f6341
Proxy settings for the Gradle wrapper can also be set through the
JAVA_OPTS
environment variable (besidesGRADLE_OPTS
). We should also pass it into the container.Other changes
analyze
andverify-policy
are referred to, from "actions" to "commands".set -u
, these functions canreturn 1
and immediately stop the script with exit code 1.