github private repo won't pull

I'll be fully honest here, I think this is an issue with the documentation. I'm using the external auth method that has been recommended here a couple times. I've gotten as far as installing the github app for my organization, and now I have a bunch of environment variables, but it's not specified what environment they need to be set in. Are these supposed to be set in the terraform code for my template? In the docker compose file that defines my coder install? somewhere else?
Solution:
OK, turns out this was a layer-8 issue, though a very subtle/frustrating one. Turns out docker compose -f coder.yml restart doesn't actually refresh the environment variables, so none of the changes I was making were getting shown to coder. This resolved itself after I used docker compose ... down followed by docker compose ... up -d. Edit to add:...
Jump to solution
5 Replies
Codercord
Codercord4w ago
<#1322449893058547833>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
arkevorkhat
arkevorkhatOP4w ago
Tried sticking it in compose and adding
data "coder_external_auth" "github" {
id = "github"
}
data "coder_external_auth" "github" {
id = "github"
}
to my terraform. Now i can get as far as clicking the Login with GitHub button, which promptly directs me to a 404 page.
Solution
arkevorkhat
arkevorkhat4w ago
OK, turns out this was a layer-8 issue, though a very subtle/frustrating one. Turns out docker compose -f coder.yml restart doesn't actually refresh the environment variables, so none of the changes I was making were getting shown to coder. This resolved itself after I used docker compose ... down followed by docker compose ... up -d. Edit to add: The final solution was the following:
Coder.yml (Docker compose)
services:
coder:
environment:
...
CODER_EXTERNAL_AUTH_0_ID: "github-auth"
CODER_EXTERNAL_AUTH_0_TYPE: "github"
CODER_EXTERNAL_AUTH_0_CLIENT_ID: <nope>
CODER_EXTERNAL_AUTH_0_CLIENT_SECRET: <lolno>
...
services:
coder:
environment:
...
CODER_EXTERNAL_AUTH_0_ID: "github-auth"
CODER_EXTERNAL_AUTH_0_TYPE: "github"
CODER_EXTERNAL_AUTH_0_CLIENT_ID: <nope>
CODER_EXTERNAL_AUTH_0_CLIENT_SECRET: <lolno>
...
main.tf (terraform source code for template)
...
data "coder_workspace_owner" "me" {}
data "coder_external_auth" "github" {
id = "github-auth" # or whatever you set CODER_EXTERNAL_AUTH_0_ID to be
}
...
locals {
envbuilder_env = {
...
"ENVBUILDER_GIT_USERNAME": data.coder_external_auth.github.access_token
}
...
}
...
data "coder_workspace_owner" "me" {}
data "coder_external_auth" "github" {
id = "github-auth" # or whatever you set CODER_EXTERNAL_AUTH_0_ID to be
}
...
locals {
envbuilder_env = {
...
"ENVBUILDER_GIT_USERNAME": data.coder_external_auth.github.access_token
}
...
}
Once you've made those additions, built, and published your template, you can then start to create a workspace, authenticate with github, and finally provide the https link to your private repository. Some pitfalls to watch out for: * If you're getting a 404 error, check the following: * that the callback url in the github url matches the one you put into your app * that the client id matches your github app
Phorcys
Phorcys4w ago
thanks for the detailed solution :)
Codercord
Codercord4w ago
@Phorcys closed the thread.

Did you find this page helpful?