Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ It is very simple to develop the development container.
You can change files related to the container and then simply run the `scripts/*`.
They are used by the CI, but especially the build and test scripts can be run also locally out of the box:
````console
$ ./scripts/build.sh
$ ./scripts/build.sh [labels]
[... build output..]
{"outcome":"success","imageName":["ghcr.io/eclipse-score/devcontainer"]}

Expand Down
82 changes: 78 additions & 4 deletions scripts/create_builder.sh
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
17 changes: 17 additions & 0 deletions src/s-core-devcontainer/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
ARG VARIANT="noble"

# Proxy arguments for build-time network access
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG http_proxy
ARG https_proxy
ARG NO_PROXY
ARG no_proxy

FROM buildpack-deps:${VARIANT}-curl

# Set proxy environment variables for the build process
ENV HTTP_PROXY=${HTTP_PROXY}
ENV HTTPS_PROXY=${HTTPS_PROXY}
ENV http_proxy=${http_proxy}
ENV https_proxy=${https_proxy}
ENV NO_PROXY=${NO_PROXY}
ENV no_proxy=${no_proxy}

LABEL dev.containers.features="common"

ARG VARIANT
Expand Down
11 changes: 10 additions & 1 deletion src/s-core-devcontainer/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"build": {
// Installs latest version from the Distribution
"dockerfile": "./Dockerfile",
"context": "."
"context": ".",
"args": {
"HTTP_PROXY": "${localEnv:HTTP_PROXY}",
"HTTPS_PROXY": "${localEnv:HTTPS_PROXY}",
"http_proxy": "${localEnv:http_proxy}",
"https_proxy": "${localEnv:https_proxy}",
"NO_PROXY": "${localEnv:NO_PROXY}",
"no_proxy": "${localEnv:no_proxy}"
}
},
"features": {
"ghcr.io/devcontainers/features/common-utils": {
Expand Down Expand Up @@ -40,6 +48,7 @@
"./s-core-local"
],
"remoteUser": "vscode",
"postStartCommand": "bash -c 'for var in HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NO_PROXY no_proxy; do [ -z \"${!var}\" ] && unset $var || true; done'",
Copy link
Contributor

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:

vscode ➜ /workspaces/inc_mw_com (example_trait_impl) $ cat .devcontainer/devcontainer.json 
{
    "name": "eclipse-s-core",
    // "image": "ghcr.io/eclipse-score/devcontainer:rustup-completion-amd64"
    "image": "ghcr.io/eclipse-score/devcontainer:proxy-settings-amd64"
    // "image": "ghcr.io/eclipse-score/devcontainer:fix-setting-bazel-version-amd64"
}
vscode ➜ /workspaces/inc_mw_com (example_trait_impl) $ env | grep -i proxy
no_proxy=
https_proxy=
NO_PROXY=
HTTPS_PROXY=
HTTP_PROXY=
http_proxy=

Copy link
Author

@olivembo olivembo Nov 12, 2025

Choose a reason for hiding this comment

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

You are right. The postStartCommand runs 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 .bashrc in the postStartCommand. The .bashrc is 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.

Copy link
Contributor

@lurtz lurtz Nov 13, 2025

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

"customizations": {
"vscode": {
"extensions": [
Expand Down
11 changes: 11 additions & 0 deletions src/s-core-devcontainer/.devcontainer/s-core-local/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ apt-get install -y python${python_version} python3-pip python3-venv
# devcontainer feature "python" (cf. https://github.com/devcontainers/features/tree/main/src/python )
apt-get install -y flake8 python3-autopep8 black python3-yapf mypy pydocstyle pycodestyle bandit pipenv virtualenv python3-pytest pylint

# OpenJDK JRE and CA certificates, via APT
# Required for Bazel to work with corporate proxy/CA certificates
apt-get install -y --no-install-recommends ca-certificates-java openjdk-${openjdk_version}-jre-headless
Copy link
Contributor

Choose a reason for hiding this comment

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

Specifying the Java version here is IMHO ok, because there are different versions as apt packages available for the same Ubuntu release.


# Bazelisk, directly from GitHub
# Using the existing devcontainer feature is not optimal:
# - it does not check the SHA256 checksum of the downloaded file
Expand All @@ -63,6 +67,10 @@ mkdir -p /etc/bash_completion.d
mv /tmp/bazel-complete.bash /etc/bash_completion.d/bazel-complete.bash
sh -c "echo 'export USE_BAZEL_VERSION=${bazel_version}' >> /etc/profile.d/bazel.sh"

# Configure Bazel to use system trust store for SSL/TLS connections
# This is required for corporate environments with custom CA certificates
echo 'startup --host_jvm_args=-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts --host_jvm_args=-Djavax.net.ssl.trustStorePassword=changeit' >> /etc/bazel.bazelrc

# Buildifier, directly from GitHub (apparently no APT repository available)
# The version is pinned to a specific release, and the SHA256 checksum is provided by the devcontainer-features.json file.
BUILDIFIER_VARIANT="amd64"
Expand Down Expand Up @@ -105,6 +113,9 @@ apt-get install -y --no-install-recommends --fix-broken qemu-system-arm="${qemu_
# sshpass
apt-get install -y sshpass="${sshpass_version}*"

# gdb (GNU Debugger)
apt-get install -y gdb="${gdb_version}*"
Comment on lines +116 to +117
Copy link
Contributor

Choose a reason for hiding this comment

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

@opajonk Do we really have to specify the tool version, if it just installed via apt-get? E.g. Python tooling is not installed with a specific version either: https://github.com/etas-contrib/score_devcontainer/blob/8aae83706ce51796b85894cdd2c6c0bc29901e84/src/s-core-devcontainer/.devcontainer/s-core-local/install.sh#L41

We already have a Ubuntu release set, which defines the versions of these tools. And thus defining the versions for each tool feels redundant.


# Cleanup
# REMOVE CONTAINER BUILD DEPENDENCIES
apt-get remove --purge -y apt-transport-https
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ qemu_system_arm:
sshpass:
version: 1.09

gdb:
version: "15.0"

git:
version: "2.43.0"

Expand All @@ -19,6 +22,9 @@ git_lfs:
python:
version: "3.12"

openjdk:
version: "17"

bazel:
# https://github.com/bazelbuild/bazel/releases -- latest version as of 2025-09-24
version: 8.4.1
Expand Down