Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(examples/templates/gcp-devcontainer): add envbuilder provider#14405

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 6 commits intomainfromcj/examples/gcp-devcontainer
Aug 23, 2024

Conversation

johnstcn
Copy link
Member

This PR modifies the gcp-devcontainer example template to include support for devcontainer caching using the envbuilder provider.

This PR modifies the gcp-devcontainer example template to includesupport for devcontainer caching using the envbuilder provider.
Copy link
Member

@matifalimatifali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A minor suggestion to use the latest module version. Otherwise looks good to me.
Thank you for doing it 😊

}

variable "cache_repo_docker_config_path" {
default = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is there any standard path we can suggest here or mention in the description?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'll mention~/.docker/config.json but it'll depend heavily on their setup.

data "coder_parameter" "devcontainer_builder" {
description = <<-EOF
Image that will build the devcontainer.
We highly recommend using a specific release as the `:latest` tag will change.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe rephrase it to indicate it is dangerous? For example: Do not useenvbuilder:latest tag due to the risk of build instability.

johnstcn reacted with thumbs up emoji
Comment on lines 175 to 180
# If we have a cached image, use the cached image's environment variables. Otherwise, just use
# the environment variables we've defined above.
docker_env_input = try(envbuilder_cached_image.cached.0.env_map, local.envbuilder_env)
# Convert the above to the list of arguments for the Docker run command. This is going to end
# up in our startup script metadata. These are all terminated by backslashes.
docker_env_arg_list = [for k, v in local.docker_env_input : " -e \"${k}=${v}\" \\"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should user modify these locals? If not, maybe indicate that in a comment.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yeah probably not :D

type = string
}

variable "insecure_cache_repo" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This changeset is relatively big, so is the.tf file. Maybe wipe out this variable?

johnstcn reacted with thumbs up emoji
variable "project_id" {
description = "Which Google Compute Project should your workspace live in?"
}

variable "cache_repo" {
default = ""
description = "(Optional) Use a container registry as a cache to speed up builds."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

People may be struggling whethercache_repo is a path, URI, endpoint, etc.

matifali reacted with thumbs up emoji
@@ -6,16 +6,49 @@ terraform {
google = {
source = "hashicorp/google"
}
envbuilder = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

curious: will we support the original form withoutenvbuilder? if so, should we add a new example likegcp-devcontainer?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Theenvbuilder provider only gets used ifcache_repo is set.

Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice work 🎉

docker_env_input = try(envbuilder_cached_image.cached.0.env_map, local.envbuilder_env)
# Convert the above to the list of arguments for the Docker run command. This is going to end
# up in our startup script metadata. These are all terminated by backslashes.
docker_env_arg_list = [for k, v in local.docker_env_input : " -e \"${k}=${v}\" \\"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This conversion might have trouble with some inputs, writing to an env file and referencing that is an alternative as it doesn't require quoting. Newline inputs could still spell trouble though.

Copy link
MemberAuthor

@johnstcnjohnstcnAug 23, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Something like this?

printf %s "<base64-encoded string>" | base64 -d > env.list

auth = "token"
os = "linux"
dir = "/workspaces/${trimsuffix(basename(data.coder_parameter.repo_url.value), ".git")}"
connection_timeout = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does setting this to zero actually serve a purpose? Doesn't it just use the default of 30s in this case?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Unsure; this was from the original template IIRC.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

OK, so from readinghttps://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent#connection_timeout I could imagine that this is set to avoid the agent showing up as 'timed out' due to the GCP instance potentially taking a long time to start.

johnstcnand others added5 commitsAugust 23, 2024 16:00
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>Co-authored-by: Muhammad Atif Ali <atif@coder.com>
@johnstcnjohnstcn merged commit53e5746 intomainAug 23, 2024
27 checks passed
@johnstcnjohnstcn deleted the cj/examples/gcp-devcontainer branchAugust 23, 2024 16:36
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 23, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mtojekmtojekmtojek left review comments

@mafredrimafredrimafredri approved these changes

@matifalimatifalimatifali approved these changes

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@johnstcn@mafredri@matifali@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp