-
Notifications
You must be signed in to change notification settings - Fork 15
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
Using environment variables in .scuba.yml or passing them #88
Comments
Hi @mpdude. Thanks for the well thought-out report! You're right, currently Scuba doesn't do much with environment variables, but I think it would certainly be a valuable addition. I started to bump into this issue when I noted #85. Scuba does support passing environment variables to Docker, but it's not yet exposed to the user. Currently To reply to a couple of your points:
AFAIK, Docker doesn't pass anything from the shell into a container; you get a pretty "clean" environment, and I'm sure this is by design. There isn't any way for software to automatically "know" which env vars to pass through and which ones to filter out. That's not to say that
There is no documented list, but perhaps that should change.
Actually, I don't think it would have to change. I've realized there is a gap in the In the image: debian:8
aliases:
simple: echo 'a simple alias'
complex:
script:
- echo "This is a complex script"
- echo "We can use variables like \$FOO=$FOO"
env:
FOO: 42
BAR: $BAR # pull from env. during scuba invocation I think what I've shown here will also work for pulling environment variables during scuba invocation. |
Also related is #80. |
@jreinhart have you thought about how you'd like the expansion of variables to work during scuba invocation? In your example above you use
The main solutions seem to be:
Solution 4 seems like the most robust solution to me, as long as we can get the escaping correct for the |
In an offline discussion with @JonathonReinhart, it was decided that full parameter expansion wasn't necessary. Instead, it would be sufficient to set environmental variables to static values, or to expand their value from the host environment. The following syntax would then be acceptable in any Scubafile:
Values that weren't mapped would be resolved from the host's environment, falling back to the empty string if the variable was not defined in the host environment. The |
I think it is easiest to simply follow the method of docker-compose:
environment:
RACK_ENV: development
SHOW: 'true'
SESSION_SECRET:
environment:
- RACK_ENV=development
- SHOW=true
- SESSION_SECRET |
Is it already possible – or do you consider it a valuable addition – to use environment variables in the
.scuba.yml
file?For one, these could be already present in the shell where
scuba
is run. Additionally, I think some variables added byscuba
might be helpful. (Is there a list of already used variables available somewhere, like the directory wherescuba
was started, path and directory to.scubafile.yml
etc.)?The goal would be do define an alias like
build: ./do-build.sh ${SCUBA_HOME} ${SOME_ENV}
.With regard to passing environment variables into the container, what about a new configuration setting, either global or per-alias, that lists env vars to be passed?
Note that we'd probably need to change the alias syntax somewhat or allow another structure to place the
env
key.This would add
-e THIS_VAR -e THAT_VAR
to thedocker run
command when using thebuild
alias, and add-e TARGET_ARCH -e COMPILE_MODE
in any case.Does that make sense?
The text was updated successfully, but these errors were encountered: