how to use files in script after cloning a repository?
I'd like to use some files that comes from a repository.
The ideal use case is:
- clone the repository, using module "git-clone"
- use a file from this repository as the script parameter of resource "coder_script"
21 Replies
<#1299375544500228096>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
I tried a workaround and used the parameter in a coder_script resource.
but the call happen before the clone is done.
the part of the template is:
and I add a setup.sh file in the Coder template configuration.
the thing I try to obtain was done with Gitpod previously.
the code is public in https://github.com/devrel-workshop/101-AI-and-py
the .gitpod.ym file was sourcing a script (yeah, I have still a lot of road to go with Coder to do the same 😉 )
try setting
depends_on = [ coder_script.git_clone ]
honestly it looks like you might be better off with devcontainers given your workflow
i've seen this issue in the past before though, we might want to add a run_after_clone
argument or somethingI know, we already have a devcontainer for local dev in case of network issue. But I thought this feature was still alpha
I'm trying this
not anymore!
ah yeah
I think you should do the cloning directly in your
coder_script
so I tried the "baby steps" approach but since the beginning I knew the devcontainer was the way
the issue is that with the module i don't think you have any way to know when it's done cloning
but in the end, I won't be able to source the script to have environment variable... so let's have a look at devcontainer
why not?
this isn't the prettiest but it should do the job
I understood this but you won't be able to have env variable in the end except if coder_script has a syntax to
@Atif do you have another idea?
oh so you mean that the env variables have to be defined in the terminal session when a user opens it?
yes, this was the way we were able to provide the attendee a full environment for the workshop with specific env variables as API token and such
i see what you mean
yeah except adding it to
/etc/profile.d
or the .bashrc
/.whateverrc
i don't think there's a straightforward way to infer env variables from coder_script
sIf this useful, I can describe the compete use case to you or any interested product manager or tech lead
being able to have those variable is the base for our workshop.
do you think this is possible with the devcontainer approach?
well, i don't think devcontainers would solve this issue really
because devcontainers still need the variable to be set at some point at build time (of the image)
except doing something like this, i'm not sure how you would achieve that
I can hop on a call if you want
I'm available for the next 20 minutes, I don't know if it is possible for you
sure, let me get on my desktop computer
you can join https://discord.com/channels/747933592273027093/1204825825476616202
Resources :
- https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace
- https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http
Devcontainers :
- Kubernetes : https://github.com/coder/coder/tree/main/examples/templates/devcontainer-kubernetes
- AWS + hashicorp/cloud-init provider : https://github.com/coder/coder/tree/aws-devcontainer-cloudinit/examples/templates/aws-devcontainer
thanks a lot, I now have a lot of readings 😉
@Phorcys closed the thread.