Skip to content

Commit 4cf6ea6

Browse files
authored
Add devcontainer based on up-rust devcontainer
1 parent 0bceeb2 commit 4cf6ea6

13 files changed

Lines changed: 424 additions & 1 deletion

File tree

.devcontainer/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
################################################################################
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
################################################################################
13+
14+
FROM mcr.microsoft.com/devcontainers/rust:latest
15+
ARG USERNAME=vscode
16+
ARG TARGETARCH
17+
18+
RUN apt-get update && \
19+
export DEBIAN_FRONTEND=noninteractive && \
20+
apt-get -y install \
21+
curl \
22+
gcc \
23+
git \
24+
openjdk-17-jre \
25+
zip \
26+
libclang-dev \
27+
&& \
28+
rm -rf /var/lib/apt/lists/*
29+
30+
# Download openfasttrace JARs and create shortcut oft executable
31+
ARG OFT_CORE_VERSION=4.1.0
32+
ARG OFT_ASCIIDOC_PLUGIN_VERSION=0.3.0
33+
ENV LIB_DIR=/opt/oft/lib
34+
RUN mkdir -p $LIB_DIR \
35+
&& base_url=https://github.com/itsallcode \
36+
&& wget -P $LIB_DIR ${base_url}/openfasttrace/releases/download/$OFT_CORE_VERSION/openfasttrace-$OFT_CORE_VERSION.jar \
37+
&& wget -P $LIB_DIR ${base_url}/openfasttrace-asciidoc-plugin/releases/download/$OFT_ASCIIDOC_PLUGIN_VERSION/openfasttrace-asciidoc-plugin-$OFT_ASCIIDOC_PLUGIN_VERSION-with-dependencies.jar \
38+
&& echo '#!/bin/bash\n\njava -cp "${LIB_DIR}/*" org.itsallcode.openfasttrace.core.cli.CliStarter "$@"' > /usr/local/bin/oft \
39+
&& chmod +x /usr/local/bin/oft
40+
41+
# Before installing cargo tools, change to the user that will be used in the container later.
42+
# The reason is that cargo creates some cache, etc. folders with the correct group rustlang, but
43+
# without making them group writable. Easiest fix is to change to the correct user before the install,
44+
# so that the owner is correct from the start.
45+
USER ${USERNAME}
46+
47+
# Install cargo cli tools
48+
RUN cargo install cargo-nextest cargo-deny cargo-tarpaulin --locked

.devcontainer/devcontainer.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// ################################################################################
2+
// Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
//
4+
// See the NOTICE file(s) distributed with this work for additional
5+
// information regarding copyright ownership.
6+
//
7+
// This program and the accompanying materials are made available under the
8+
// terms of the Apache License Version 2.0 which is available at
9+
// https: //www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
// ################################################################################
13+
//
14+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
15+
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
16+
{
17+
"name": "up-transport-iceoryx2-rust",
18+
"build": {
19+
"dockerfile": "Dockerfile"
20+
},
21+
"runArgs": [
22+
"--privileged"
23+
],
24+
"containerEnv": {
25+
"WORKSPACE_FOLDER": "${containerWorkspaceFolder}"
26+
},
27+
"mounts": [
28+
{
29+
// This is a workaround which is again necessary on MacOS 14.0, it looks like this bug is back:
30+
// https://github.com/microsoft/vscode-dev-containers/issues/1487#issuecomment-1143907307
31+
"type": "volume",
32+
"source": "rust-volume",
33+
"target": "/rust-volume"
34+
},
35+
{
36+
"type": "bind",
37+
"source": "${localWorkspaceFolder}/.devcontainer/scripts",
38+
"target": "/home/vscode/scripts"
39+
},
40+
{
41+
"type": "bind",
42+
"source": "${localEnv:HOME}${localEnv:USERPROFILE}/.ssh",
43+
"target": "/home/vscode/.ssh"
44+
}
45+
],
46+
"postCreateCommand": ".devcontainer/scripts/post-create.sh --workspace-folder='${containerWorkspaceFolder}'",
47+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/${localWorkspaceFolderBasename}/,type=bind",
48+
"workspaceFolder": "/workspace/${localWorkspaceFolderBasename}/",
49+
"remoteUser": "vscode",
50+
"customizations": {
51+
"vscode": {
52+
// Set *default* container specific settings.json values on container create.
53+
"settings": {
54+
"lldb.executable": "/usr/bin/lldb",
55+
// VS Code don't watch files under ./target
56+
"files.watcherExclude": {
57+
"**/target/**": true
58+
},
59+
"rust-analyzer.check.command": "clippy",
60+
"rust-analyzer.checkOnSave": true,
61+
"coverage-gutters.coverageBaseDir": "**",
62+
"coverage-gutters.coverageFileNames": [
63+
"target/tarpaulin/lcov.info"
64+
]
65+
},
66+
// Add the IDs of extensions you want installed when the container is created.
67+
"extensions": [
68+
"asciidoctor.asciidoctor-vscode",
69+
"bianxianyang.htmlplay",
70+
"bierner.markdown-mermaid",
71+
"bierner.markdown-preview-github-styles",
72+
"davidanson.vscode-markdownlint",
73+
"gxl.git-graph-3",
74+
"hediet.vscode-drawio",
75+
"linusu.auto-dark-mode",
76+
"ms-azuretools.vscode-containers",
77+
"rust-lang.rust-analyzer",
78+
"streetsidesoftware.code-spell-checker",
79+
"tamasfe.even-better-toml",
80+
"timonwong.shellcheck",
81+
"vadimcn.vscode-lldb",
82+
"yzhang.markdown-all-in-one"
83+
]
84+
}
85+
}
86+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
################################################################################
3+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
4+
#
5+
# See the NOTICE file(s) distributed with this work for additional
6+
# information regarding copyright ownership.
7+
#
8+
# This program and the accompanying materials are made available under the
9+
# terms of the Apache License Version 2.0 which is available at
10+
# https: //www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# SPDX-License-Identifier: Apache-2.0
13+
################################################################################
14+
15+
if [ -d "$HOME/.ssh" ]; then
16+
source ${WORKSPACE_FOLDER}/.devcontainer/scripts/ensure-ssh-permissions.sh
17+
fi
18+
source ${WORKSPACE_FOLDER}/.devcontainer/scripts/colors.sh
19+
20+
PRIMARY_COLOR=$COLOR_GRAY
21+
SECONDARY_COLOR=$COLOR_NC
22+
INFO_COLOR=$COLOR_CYAN
23+
24+
WELCOME_INFO="${SECONDARY_COLOR}
25+
██ ██ ███████ ██ ██████ ██████ ███ ███ ███████
26+
██ ██ ██ ██ ██ ██ ██ ████ ████ ██
27+
██ █ ██ █████ ██ ██ ██ ██ ██ ████ ██ █████
28+
██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
29+
███ ███ ███████ ███████ ██████ ██████ ██ ██ ███████
30+
${PRIMARY_COLOR}
31+
to the Eclipse Foundation ${INFO_COLOR}$(basename "$WORKSPACE_FOLDER")${PRIMARY_COLOR} code repository
32+
33+
Workspace Folder ${SECONDARY_COLOR}$WORKSPACE_FOLDER
34+
35+
${INFO_COLOR}Library Version(s)${PRIMARY_COLOR}
36+
Rust Version ${SECONDARY_COLOR}$(rustc --version)${PRIMARY_COLOR}
37+
Cargo Version ${SECONDARY_COLOR}$(cargo --version)${PRIMARY_COLOR}
38+
39+
${INFO_COLOR}Git${PRIMARY_COLOR}
40+
Username ${SECONDARY_COLOR}$(git config user.name)${PRIMARY_COLOR}
41+
Email ${SECONDARY_COLOR}$(git config user.email)${PRIMARY_COLOR}
42+
43+
to see this info again, use the ${INFO_COLOR}welcome${PRIMARY_COLOR} command${COLOR_NC}
44+
"
45+
46+
alias welcome='printf "$WELCOME_INFO"'
47+
welcome

.devcontainer/scripts/colors.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
################################################################################
3+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
4+
#
5+
# See the NOTICE file(s) distributed with this work for additional
6+
# information regarding copyright ownership.
7+
#
8+
# This program and the accompanying materials are made available under the
9+
# terms of the Apache License Version 2.0 which is available at
10+
# https: //www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# SPDX-License-Identifier: Apache-2.0
13+
################################################################################
14+
15+
export COLOR_NC='\e[0m' # No Color
16+
export COLOR_BLACK='\e[0;30m'
17+
export COLOR_GRAY='\e[1;30m'
18+
export COLOR_RED='\e[0;31m'
19+
export COLOR_LIGHT_RED='\e[1;31m'
20+
export COLOR_GREEN='\e[0;32m'
21+
export COLOR_LIGHT_GREEN='\e[1;32m'
22+
export COLOR_BROWN='\e[0;33m'
23+
export COLOR_YELLOW='\e[1;33m'
24+
export COLOR_BLUE='\e[0;34m'
25+
export COLOR_LIGHT_BLUE='\e[1;34m'
26+
export COLOR_PURPLE='\e[0;35m'
27+
export COLOR_LIGHT_PURPLE='\e[1;35m'
28+
export COLOR_CYAN='\e[0;36m'
29+
export COLOR_LIGHT_CYAN='\e[1;36m'
30+
export COLOR_LIGHT_GRAY='\e[0;37m'
31+
export COLOR_WHITE='\e[1;37m'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
################################################################################
3+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
4+
#
5+
# See the NOTICE file(s) distributed with this work for additional
6+
# information regarding copyright ownership.
7+
#
8+
# This program and the accompanying materials are made available under the
9+
# terms of the Apache License Version 2.0 which is available at
10+
# https: //www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# SPDX-License-Identifier: Apache-2.0
13+
################################################################################
14+
15+
# Sometimes when mounting volumes, the files unexpectedly change their read-write-execute status.
16+
# This is dependent on the OS the Docker container is mounting from, and how it exposes its
17+
# files permissions, ownership, and "executability" to the container and the containers user.
18+
#
19+
# More about specific permissions inside the .ssh folder
20+
# https://serverfault.com/a/253314
21+
sudo find ~/.ssh -maxdepth 1 -type f -exec chmod 600 {} \;
22+
chmod u+r ~/.ssh/config
23+
chmod u+r ~/.ssh/known_hosts
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
################################################################################
3+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
4+
#
5+
# See the NOTICE file(s) distributed with this work for additional
6+
# information regarding copyright ownership.
7+
#
8+
# This program and the accompanying materials are made available under the
9+
# terms of the Apache License Version 2.0 which is available at
10+
# https: //www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# SPDX-License-Identifier: Apache-2.0
13+
################################################################################
14+
15+
get_arch_and_os() {
16+
ARCH=$(uname -m)
17+
OS=$(uname -s | tr "[:upper:]" "[:lower:]")
18+
19+
case "$ARCH" in
20+
x86_64)
21+
TARGET_ARCH="x86_64"
22+
;;
23+
aarch64 | arm64)
24+
TARGET_ARCH="aarch64"
25+
;;
26+
*)
27+
echo "Unsupported architecture: $ARCH"
28+
exit 1
29+
;;
30+
esac
31+
32+
case "$OS" in
33+
linux)
34+
TARGET_OS="unknown-linux-gnu"
35+
;;
36+
*)
37+
echo "OS is unsupported or not implemented in this script: $OS"
38+
exit 1
39+
;;
40+
esac
41+
echo "$TARGET_ARCH $TARGET_OS"
42+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
################################################################################
3+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
4+
#
5+
# See the NOTICE file(s) distributed with this work for additional
6+
# information regarding copyright ownership.
7+
#
8+
# This program and the accompanying materials are made available under the
9+
# terms of the Apache License Version 2.0 which is available at
10+
# https: //www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# SPDX-License-Identifier: Apache-2.0
13+
################################################################################
14+
15+
install_rust_toolchain() {
16+
source ${WORKSPACE_FOLDER}/.devcontainer/scripts/functions/get-arch-and-os.sh
17+
read -r TARGET_ARCH TARGET_OS <<< "$(get_arch_and_os)"
18+
ARCH_AND_OS="${TARGET_ARCH}-${TARGET_OS}"
19+
echo "Detected architecture and OS: $ARCH_AND_OS"
20+
RUST_TOOLCHAIN="stable-$ARCH_AND_OS"
21+
if rustup toolchain list | grep -q $RUST_TOOLCHAIN; then
22+
echo "Rust toolchain '$RUST_TOOLCHAIN' is already installed."
23+
return 0
24+
fi
25+
echo "Adding rustup target '$ARCH_AND_OS'"
26+
rustup target add "$ARCH_AND_OS"
27+
echo "Installing Rust toolchain for '$ARCH_AND_OS'"
28+
rustup toolchain install "$RUST_TOOLCHAIN"
29+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
################################################################################
3+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
4+
#
5+
# See the NOTICE file(s) distributed with this work for additional
6+
# information regarding copyright ownership.
7+
#
8+
# This program and the accompanying materials are made available under the
9+
# terms of the Apache License Version 2.0 which is available at
10+
# https: //www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# SPDX-License-Identifier: Apache-2.0
13+
################################################################################
14+
15+
#region sudo stuff
16+
17+
HOST_OS=""
18+
ARCH_AND_OS_FUNC="${WORKSPACE_FOLDER}/.devcontainer/scripts/functions/get-arch-and-os.sh"
19+
if [[ -f "$ARCH_AND_OS_FUNC" ]]; then
20+
source $ARCH_AND_OS_FUNC
21+
read -r _ HOST_OS <<< "$(get_arch_and_os)"
22+
fi
23+
if [[ "$HOST_OS" == "darwin" ]]; then # darwin == Mac OS
24+
# This is a workaround which is againt necessary on MacOS 14.0, it looks like this bug is back:
25+
# https://github.com/microsoft/vscode-dev-containers/issues/1487#issuecomment-1143907307
26+
# grant permissions to mounted rust volume
27+
echo "(Mac OS only) Granting permissions to mounted rust volume"
28+
sudo chown vscode:vscode /rust-volume
29+
30+
# create /.cargo/config.toml in root folder
31+
sudo mkdir /.cargo/
32+
sudo touch /.cargo/config.toml
33+
sudo bash -c "cat << EOF > /.cargo/config.toml
34+
[build]
35+
target-dir = \"/rust-volume/target\"
36+
EOF"
37+
fi
38+
39+
if ! grep -q "bashrc_addition" ~/.bashrc && [[ -f "${WORKSPACE_FOLDER}/.devcontainer/scripts/bashrc_addition.sh" ]]; then
40+
echo "source ${WORKSPACE_FOLDER}/.devcontainer/scripts/bashrc_addition.sh" >> ~/.bashrc
41+
fi
42+
43+
#endregion
44+
45+
for arg in "$@"; do
46+
if [[ "$arg" == --workspace-folder=* ]]; then
47+
WORKSPACE_FOLDER="${arg#--workspace-folder=}"
48+
fi
49+
done
50+
INSTALL_RUST_TOOLCHAIN_FUNC="${WORKSPACE_FOLDER}/.devcontainer/scripts/functions/install-rust-toolchain.sh"
51+
if [[ -f "$INSTALL_RUST_TOOLCHAIN_FUNC" ]]; then
52+
source $INSTALL_RUST_TOOLCHAIN_FUNC
53+
install_rust_toolchain "$@"
54+
fi

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1+
# ################################################################################
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https: //www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# ################################################################################
13+
114
* text=auto eol=lf

.github/workflows/check.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
name: Rust Project CI
1+
################################################################################
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https: //www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
################################################################################name: Rust Project CI
213

314
on:
415
push:

0 commit comments

Comments
 (0)