Skip to content
Draft
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 .devcontainer/post_create_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
npm install -g @devcontainers/cli
pre-commit install

scripts/create_builder.sh
# scripts/create_builder.sh

sudo apt-get update && sudo apt-get install -y shellcheck
39 changes: 26 additions & 13 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,32 @@ done

echo "Building all labels (" "${LABELS[@]}" ") for architecture: ${ARCH}"

# Prepare image names with tags (each tag includes a label and the architecture)
IMAGES=()
for LABEL in "${LABELS[@]}"; do
IMAGES+=("--image-name \"ghcr.io/eclipse-score/devcontainer:${LABEL}-${ARCH}\"")
done
function build_container() {
local name="$1"

# Prepare devcontainer build command
DEVCONTAINER_CALL="devcontainer build --workspace-folder src/s-core-devcontainer --cache-from ghcr.io/eclipse-score/devcontainer"
# Prepare image names with tags (each tag includes a label and the architecture)
IMAGES=()
for LABEL in "${LABELS[@]}"; do
IMAGES+=("--image-name \"ghcr.io/eclipse-score/${name}:${LABEL}-${ARCH}\"")
done

# Append image names to the build command
for IMAGE in "${IMAGES[@]}"; do
DEVCONTAINER_CALL+=" ${IMAGE}"
done
# Prepare devcontainer build command
DEVCONTAINER_CALL="devcontainer build --workspace-folder src/s-core-${name} --cache-from ghcr.io/eclipse-score/${name}"
# DEVCONTAINER_CALL+=" --output=type=docker,push=true,platform=linux/${ARCH}"

# Append image names to the build command
for IMAGE in "${IMAGES[@]}"; do
DEVCONTAINER_CALL+=" ${IMAGE}"
done

# Execute the build for the specific architecture
eval "${DEVCONTAINER_CALL} --platform linux/${ARCH}"
}

# TODO: this is a workaround so that the devcontainer build can use the buildcontainer image
# but it reverts any action done in scripts/create_builder.sh and cannot be merged to main
# docker buildx use default

# Execute the build for the specific architecture
eval "${DEVCONTAINER_CALL} --platform linux/${ARCH}"
# Build the containers
build_container "buildcontainer"
build_container "devcontainer"
39 changes: 26 additions & 13 deletions scripts/merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

set -euxo pipefail

SCRIPT_PATH=$(readlink -f "$0")
SCRIPT_DIR=$(dirname -- "${SCRIPT_PATH}")

if [ "$#" -eq 0 ]; then
echo "Error: At least one parameter (label) must be provided."
exit 1
Expand All @@ -29,22 +32,32 @@ done
# Define target architectures
ARCHITECTURES=("amd64" "arm64")

# Pull all architecture-specific images for each label
for LABEL in "${LABELS[@]}"; do
for ARCH in "${ARCHITECTURES[@]}"; do
docker pull --platform "linux/${ARCH}" "ghcr.io/eclipse-score/devcontainer:${LABEL}-${ARCH}"
"${SCRIPT_DIR}/create_builder.sh"

function merge_containers() {
local name="$1"

# Pull all architecture-specific images for each label
for LABEL in "${LABELS[@]}"; do
for ARCH in "${ARCHITECTURES[@]}"; do
docker pull --platform "linux/${ARCH}" "ghcr.io/eclipse-score/${name}:${LABEL}-${ARCH}"
done
done
done

# Create and push the merged multiarch manifest for each tag; each tag combines all architecture-specific tags into one tag
for LABEL in "${LABELS[@]}"; do
echo "Merging all architectures (" "${ARCHITECTURES[@]}" ") into single tag: ${LABEL}"
# Create and push the merged multiarch manifest for each tag; each tag combines all architecture-specific tags into one tag
for LABEL in "${LABELS[@]}"; do
echo "Merging all architectures (" "${ARCHITECTURES[@]}" ") into single tag: ${LABEL}"

MANIFEST_MERGE_CALL="docker buildx imagetools create -t ghcr.io/eclipse-score/${name}:${LABEL}"

MANIFEST_MERGE_CALL="docker buildx imagetools create -t ghcr.io/eclipse-score/devcontainer:${LABEL}"
for ARCH in "${ARCHITECTURES[@]}"; do
MANIFEST_MERGE_CALL+=" ghcr.io/eclipse-score/${name}:${LABEL}-${ARCH}"
done

for ARCH in "${ARCHITECTURES[@]}"; do
MANIFEST_MERGE_CALL+=" ghcr.io/eclipse-score/devcontainer:${LABEL}-${ARCH}"
eval "${MANIFEST_MERGE_CALL}"
done
}

eval "${MANIFEST_MERGE_CALL}"
done
# Merge containers
merge_containers buildcontainer
merge_containers devcontainer
37 changes: 23 additions & 14 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,29 @@ for LABEL in "$@"; do
LABELS+=("${LABEL}")
done

echo "Building all tags (" "${LABELS[@]}" ") for architecture: ${ARCH}"
# Prepare image names with tags (each tag includes a label and an architecture)
IMAGES=()
for LABEL in "${LABELS[@]}"; do
IMAGES+=("--image-name \"ghcr.io/eclipse-score/devcontainer:${LABEL}-${ARCH}\"")
done
echo "Pushing all tags (" "${LABELS[@]}" ") for architecture: ${ARCH}"

# Prepare devcontainer build command
DEVCONTAINER_CALL="devcontainer build --push --workspace-folder src/s-core-devcontainer --cache-from ghcr.io/eclipse-score/devcontainer"
push_container() {
local name="$1"

# Append image names to the build command
for IMAGE in "${IMAGES[@]}"; do
DEVCONTAINER_CALL+=" ${IMAGE}"
done
# Prepare image names with tags (each tag includes a label and an architecture)
IMAGES=()
for LABEL in "${LABELS[@]}"; do
IMAGES+=("--image-name \"ghcr.io/eclipse-score/${name}:${LABEL}-${ARCH}\"")
done

# Prepare devcontainer build command
DEVCONTAINER_CALL="devcontainer build --push --workspace-folder src/s-core-${name} --cache-from ghcr.io/eclipse-score/${name}"

# Append image names to the build command
for IMAGE in "${IMAGES[@]}"; do
DEVCONTAINER_CALL+=" ${IMAGE}"
done

# Execute the build and push all tags for the specific architecture
eval "${DEVCONTAINER_CALL} --platform linux/${ARCH}"
}

# Execute the build and push all tags for the specific architecture
eval "${DEVCONTAINER_CALL} --platform linux/${ARCH}"
# Push the containers
push_container "buildcontainer"
push_container "devcontainer"
36 changes: 22 additions & 14 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,30 @@

set -euxo pipefail

IMAGE="s-core-devcontainer"

export DOCKER_BUILDKIT=1

SCRIPT_PATH=$(readlink -f "$0")
SCRIPT_DIR=$(dirname -- "${SCRIPT_PATH}")
PROJECT_DIR=$(dirname -- "${SCRIPT_DIR}")
ID_LABEL="test-container=${IMAGE}"

devcontainer up \
--id-label "${ID_LABEL}" \
--workspace-folder "${PROJECT_DIR}/src/${IMAGE}/" \
--remove-existing-container

# Run actual test
echo "(*) Running test..."
devcontainer exec --workspace-folder "${PROJECT_DIR}/src/${IMAGE}" --id-label "${ID_LABEL}" \
/bin/sh -c 'set -e && cd test-project && \
./test.sh'

function test_container() {
local name="$1"

local IMAGE="s-core-${name}"
local ID_LABEL="test-container=${IMAGE}"

devcontainer up \
--id-label "${ID_LABEL}" \
--workspace-folder "${PROJECT_DIR}/src/${IMAGE}/" \
--remove-existing-container

# Run actual test
echo "(*) Running test..."
devcontainer exec --workspace-folder "${PROJECT_DIR}/src/${IMAGE}" --id-label "${ID_LABEL}" \
/bin/sh -c 'set -e && cd test-project && \
./test.sh'
}

# Test the containers
test_container "buildcontainer"
test_container "devcontainer"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"description": "Bazel and supplimentary tools for working with Bazel-based projects.",
"dependsOn": {
"./s-core-local": {} // needed for extracting versions (versions.sh)
"./s-core-build": {} // needed for extracting versions (versions.sh)
},
"onCreateCommand": "/devcontainer/features/bazel/on_create_command.sh",
"postCreateCommand": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rm -f "${COPY_TARGET}/devcontainer-features.env" "${COPY_TARGET}/devcontainer-fe
DEBIAN_FRONTEND=noninteractive

# Read tool versions + metadata into environment variables
. /devcontainer/features/s-core-local/versions.sh /devcontainer/features/bazel/versions.yaml
. /devcontainer/features/s-core-build/versions.sh /devcontainer/features/bazel/versions.yaml

ARCHITECTURE=$(dpkg --print-architecture)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
set -euo pipefail

# Read tool versions + metadata into environment variables
. /devcontainer/features/s-core-local/versions.sh /devcontainer/features/bazel/versions.yaml
. /devcontainer/features/s-core-build/versions.sh /devcontainer/features/bazel/versions.yaml

# Bazel-related tools
## This is the bazel version preinstalled in the devcontainer.
Expand Down
14 changes: 14 additions & 0 deletions src/s-core-buildcontainer/.devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"features": {
"ghcr.io/devcontainers-extra/features/pre-commit:2": {
"version": "2.0.18",
"resolved": "ghcr.io/devcontainers-extra/features/pre-commit@sha256:6e0bb2ce80caca1d94f44dab5d0653d88a1c00984e590adb7c6bce012d0ade6e",
"integrity": "sha256:6e0bb2ce80caca1d94f44dab5d0653d88a1c00984e590adb7c6bce012d0ade6e"
},
"ghcr.io/devcontainers/features/common-utils": {
"version": "2.5.4",
"resolved": "ghcr.io/devcontainers/features/common-utils@sha256:00fd45550f578d9d515044d9e2226e908dbc3d7aa6fcb9dee4d8bdb60be114cf",
"integrity": "sha256:00fd45550f578d9d515044d9e2226e908dbc3d7aa6fcb9dee4d8bdb60be114cf"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*******************************************************************************
Copyright (c) 2026 Contributors to the Eclipse Foundation

See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-FileCopyrightText: 2026 Contributors to the Eclipse Foundation
SPDX-License-Identifier: Apache-2.0
*******************************************************************************
35 changes: 35 additions & 0 deletions src/s-core-buildcontainer/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"build": {
// Installs latest version from the Distribution
"dockerfile": "./Dockerfile",
"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": {
// Installs latest version from the Distribution
"installZsh": "false",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "false" // WARNING: do *not* enable; this would include packages also from other features, which may have been pinned to a specific version
},
"./s-core-build": {},
"./bazel-feature": {}
},
"overrideFeatureInstallOrder": [
// this order makes it more convenient to develop the local features, since they will be installed last
// which means changes to it will be applied without needing to rebuild all other features
"ghcr.io/devcontainers/features/common-utils",
"./s-core-build",
"./bazel-feature"
],
"remoteUser": "vscode"
}
13 changes: 13 additions & 0 deletions src/s-core-buildcontainer/.devcontainer/devcontainer.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*******************************************************************************
Copyright (c) 2026 Contributors to the Eclipse Foundation

See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-FileCopyrightText: 2026 Contributors to the Eclipse Foundation
SPDX-License-Identifier: Apache-2.0
*******************************************************************************
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Eclipse S-CORE-specific essential build tools",
"id": "s-core-build",
"version": "1.0.0",
"description": "Tools which are required for building and are not available as already existing development container feature",
"dependsOn": {
"ghcr.io/devcontainers-extra/features/pre-commit:2": {
"version": "4.5.1"
}
},
"postCreateCommand": {
"Enable pre-commit hooks": "bash /devcontainer/features/s-core-build/enable_pre_commit_hooks.sh"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*******************************************************************************
Copyright (c) 2026 Contributors to the Eclipse Foundation

See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-FileCopyrightText: 2026 Contributors to the Eclipse Foundation
SPDX-License-Identifier: Apache-2.0
*******************************************************************************
Loading
Loading