-
Notifications
You must be signed in to change notification settings - Fork 6
Make devcontainer work in WSL and proxy environments #52
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
olivembo
wants to merge
8
commits into
eclipse-score:main
Choose a base branch
from
etas-contrib:make-devcontainer-also-work-in-environments-with-proxy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c4c123e
Introduced usage of proxy environment variables
olivembo ba91ed4
feat: Added proxy related functions to the create_builder.sh script
olivembo 14d8782
chore: Reverted previous changes
olivembo b80c0ba
feat: Remove empty, proxy-related environment variables if there is a…
olivembo 0976073
fix: Use bash for postStartCommand instead of sh (default)
olivembo a811a36
chore: Add OpenJDK in order to be able to configure Bazel for corpora…
olivembo 8490b2b
feat: Install gdb
olivembo f348fe8
Removed duplicate entry
olivembo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,82 @@ | ||
| #!/usr/bin/env bash | ||
| set -euxo pipefail | ||
|
|
||
| if ! docker buildx inspect multiarch &>/dev/null; then | ||
| docker buildx create --name multiarch --driver docker-container --use | ||
| else | ||
| docker buildx use multiarch | ||
| # Function to check if builder has correct proxy configuration | ||
| check_proxy_config() { | ||
| local builder_info | ||
| builder_info=$(docker buildx inspect multiarch 2>/dev/null || echo "") | ||
|
|
||
| # Check if HTTP_PROXY is set in environment but not in builder | ||
| if [ -n "${HTTP_PROXY:-}" ]; then | ||
| if ! echo "$builder_info" | grep -q "HTTP_PROXY=${HTTP_PROXY}"; then | ||
| return 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Check if HTTPS_PROXY is set in environment but not in builder | ||
| if [ -n "${HTTPS_PROXY:-}" ]; then | ||
| if ! echo "$builder_info" | grep -q "HTTPS_PROXY=${HTTPS_PROXY}"; then | ||
| return 1 | ||
| fi | ||
| fi | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
| # Check if builder exists and has correct proxy configuration | ||
| if docker buildx inspect multiarch &>/dev/null; then | ||
| if ! check_proxy_config; then | ||
| echo "Builder 'multiarch' exists but has incorrect proxy configuration. Recreating..." | ||
| docker buildx rm multiarch | ||
| else | ||
| echo "Builder 'multiarch' already exists with correct configuration." | ||
| docker buildx use multiarch | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| # Create BuildKit configuration file with proxy settings | ||
| BUILDKIT_CONFIG="" | ||
| if [ -n "${HTTP_PROXY:-}" ] || [ -n "${HTTPS_PROXY:-}" ]; then | ||
| BUILDKIT_CONFIG="${HOME}/.config/buildkit/buildkitd.toml" | ||
| mkdir -p "$(dirname "${BUILDKIT_CONFIG}")" | ||
| cat > "${BUILDKIT_CONFIG}" <<EOF | ||
| [worker.oci] | ||
| enabled = true | ||
|
|
||
| [worker.containerd] | ||
| enabled = false | ||
|
|
||
| # Default build arg values for all builds (includes proxy settings) | ||
| [worker.oci.proxy] | ||
| http = "${HTTP_PROXY:-}" | ||
| https = "${HTTPS_PROXY:-}" | ||
| noProxy = "${NO_PROXY:-}" | ||
| EOF | ||
| fi | ||
|
|
||
| # Build driver options for proxy configuration | ||
| DRIVER_OPTS=() | ||
|
|
||
| if [ -n "${HTTP_PROXY:-}" ]; then | ||
| DRIVER_OPTS+=("--driver-opt" "env.HTTP_PROXY=${HTTP_PROXY}") | ||
| fi | ||
|
|
||
| if [ -n "${HTTPS_PROXY:-}" ]; then | ||
| DRIVER_OPTS+=("--driver-opt" "env.HTTPS_PROXY=${HTTPS_PROXY}") | ||
| fi | ||
|
|
||
| if [ -n "${NO_PROXY:-}" ]; then | ||
| DRIVER_OPTS+=("--driver-opt" "env.NO_PROXY=${NO_PROXY}") | ||
| fi | ||
|
|
||
| # Add network mode to use host DNS resolution | ||
| DRIVER_OPTS+=("--driver-opt" "network=host") | ||
|
|
||
| # Add BuildKit config file if proxy is configured | ||
| if [ -n "${BUILDKIT_CONFIG}" ]; then | ||
| DRIVER_OPTS+=("--config" "${BUILDKIT_CONFIG}") | ||
| fi | ||
|
|
||
| # Create builder with driver options | ||
| docker buildx create --name multiarch --driver docker-container "${DRIVER_OPTS[@]}" --use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still does not work. Execution is now successful, but variables are still present in a new shell:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. The
postStartCommandruns in its own shell und unsets the environment variables only there.The only solution I would have at the moment, would be to append unset commands to
.bashrcin thepostStartCommand. The.bashrcis then sourced by every new bash shell and every time unsets the environment variables. But it's not a nice solution imho. Would appreciate better proposals.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can use
/etc/profile.d/for this. Here is an example where I removed using it: https://github.com/eclipse-score/devcontainer/pull/51/files#diff-e418ce180663a5c3fc806f1c352a9d737097e60cecaa9cd1724c8236a955a335R64