I'm running a self-hosted Git server at home that's not externally accessible, and I've set it up with basic HTTP authentication. I was previously using this command successfully (with my Git credentials stored in ~/.netrc): `docker build -t jwyper/ashridge http://192.168.0.96:8090/ashridge.git#release:docker`. However, after upgrading Docker, it seems to default to using Buildx, and now that command doesn't work anymore.
I came across some guidance suggesting that setting the `GIT_AUTH_HEADER` would fix the issue, but I haven't had any luck with it. I've confirmed that the username "git" and the associated password are correct by checking against the htaccess file on the server.
Here's what I tried: I base64 encoded my credentials with `echo git:password | base64` and amended my command to this: `export GIT_AUTH_HEADER="Basic base_64_encoded_text_here" && docker build --secret id=GIT_AUTH_HEADER -t jwyper/ashridge http://192.168.0.96:8090/ashridge.git#release:docker`. Yet, I keep running into an error stating it can't read the username and terminal prompts are disabled. On the server side, the Nginx logs show a password mismatch error. It feels like I'm close but missing something. I'd appreciate any help!
For now, I'm reverting to the previous build method. I understand there are alternatives to change my repo setup for connecting, but I'm frustrated that this method used to work.
3 Answers
When things get tricky, I usually comment out the latter parts of my Dockerfile and execute the initial lines with `docker exec` to troubleshoot. It's helpful to add verbose logging too. It’s often a matter of identifying whether the issue is with my commands or Docker itself. Keep in mind this might not apply directly to your case since your problem lies in fetching the Dockerfile from Git.
I actually managed to do something similar using SSH authentication instead. You can look into securely passing SSH credentials into your builds since that’s a standard approach. Check out the example on how it's done with GitHub Actions, but it can be adapted to CLI commands as well! Here’s a link to see how: https://github.com/cogini/phoenix_container_example/blob/0e9aa445295fec00100c0e5824692c14499f4c6a/deploy/debian.Dockerfile#L280.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically