#How to copy file to an environment with container-use?

1 messages · Page 1 of 1 (latest)

jolly snow
#

I'm trying to setup container-use with my legacy Rails project. In Rails there was a convention to store secrets in config/secrets.yml, which is not committed to repository, so it's not copied to environment by default. How to copy a file to environment manually?
I tried to use file reference with secrets https://container-use.com/secrets#secret-types and then do
container-use config install-command add "echo $SECRETS > ./config/secrets.yml" but now the formatting is screwed up, and the file is not valid yml.

Is there some way to do this with container-use or maybe there's an escape hatch which I can use, to use dagger for the environment directly?

#

How to copy file to an environment with container-use?

lean lagoon
#

@jolly snow i'd use an install command to write a secrets.yml that looks like this

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

and then set up a cu secret like container-use config secret set SECRET_KEY_BASE "your value here, either from an env var set on the host machine, from a pw manager, etc"

#

you could also maybe do it as a whole file, using a very similar technique as what you've already got, file://path is a supported secret protocol

#

which would be like echo $SECRETS_YML > ./config/secrets.yml as an install command, and setting the env secret like container-use config secret set SECRETS_YML file://config/secrets.yml

jolly snow
#

Yeah, that's what I'm supposed to do, I understand. But as I said it's a legacy project, and this file kind of got out of hand, and just contains a lot of configuration, that is not accessible through env variables alone. I can refactor it for sure, but that would be more work.

I was hoping there would be an easier way to just do "hey, copy this file from host here"

lean lagoon
#

yeah the file protocol will let you do that (and conveniently it'll also actually try to hide the contents of the file from logs and whatnot)

jolly snow
#

container-use config secret set SECRETS_YML file://config/secrets.yml when I did that it removed all of the indentation from contents, so it's not working straight away

#

I don't know if it's even possible to restore the indentation correctly after echo

lean lagoon
#

oh oh oh i know this one

#

echo "$SECRETS" > ./config/secrets.yml

#

the quotes

#

it's like they say, there are 3 hard problems in computer science: counting and posix shell quoting

#

(either that or we have a classic llm-written bug where something is unnecessarily stripping whitespace, but im like 70% sure it's the quotes lol)

jolly snow
#

You're right! It was those damn quotes

#

It works now, thank you

#

Should've figure this out myself. Long day..