Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
55e0750
lay way for testing container
wusatosi Apr 29, 2025
c1ed816
add infra for test containers
wusatosi Apr 29, 2025
8ef5a0d
add a test container
wusatosi Apr 29, 2025
c6c2167
create vscode user if not exist
wusatosi Apr 29, 2025
d0f0b82
update paths
wusatosi Apr 29, 2025
cb8c17b
Fix docker
wusatosi Apr 29, 2025
2ca07e0
install gpg
wusatosi Apr 29, 2025
e5f7f5f
update matrix
wusatosi Apr 29, 2025
63a9ea5
Add more basic utilities
wusatosi Apr 29, 2025
c4a2117
Add more gnu versions
wusatosi Apr 29, 2025
f88c899
constrain to latest 4 gnu versions
wusatosi Apr 29, 2025
40b774b
more llvm versions
wusatosi Apr 29, 2025
94cdc33
Update CI workflow name
wusatosi Apr 29, 2025
c20f5b9
Merge branch 'main' into test-container-ext
wusatosi Apr 30, 2025
2be898e
add ninja build
wusatosi Apr 30, 2025
1fd43cc
add libc++
wusatosi Apr 30, 2025
2b0467f
fix install
wusatosi Apr 30, 2025
e797610
refactor installation
wusatosi May 2, 2025
08cdb4c
specify libc
wusatosi May 2, 2025
c220329
Link gcov
wusatosi May 7, 2025
eba0af7
Add coverage tool
wusatosi May 7, 2025
dc94519
move lcov install to after compiler
wusatosi May 7, 2025
4fbaae2
remove gcov link
wusatosi May 7, 2025
4436d2a
relink gcov
wusatosi May 7, 2025
cefbbc0
Add llvm 21
wusatosi May 7, 2025
d3a96a0
change naming for gnu, llvm
wusatosi May 10, 2025
8d72419
gccpg -> gnupg
wusatosi May 10, 2025
9b69c43
update naming script
wusatosi May 10, 2025
6e3a3d3
Update docs
wusatosi May 11, 2025
9532de6
Merge remote-tracking branch 'origin/main' into test-container-ext
wusatosi May 11, 2025
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
69 changes: 53 additions & 16 deletions .github/workflows/build_devcontainer.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,80 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: Publish Beman devcontainers
name: Publish Beman Containers

on:
push:
paths:
- ".github/workflows/build_devcontainer.yml"
- "devcontainer/**"
- "containers/**"
workflow_dispatch:

env:
REGISTRY: ghcr.io
DEBUG_IMAGE_NAME: ${{ github.repository }}
DEPLOY_IMAGE_NAME: bemanproject/devcontainers
DEBUG_NAME: ${{ github.repository }}
DEPLOY_DEV_NAME_PREFIX: bemanproject/devcontainers
DEPLOY_TESTING_NAME_PREFIX: bemanproject/testingcontainers
BASE_IMAGE_DEV: mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
BASE_IMAGE_TEST: ubuntu:24.04

permissions:
packages: write

jobs:
build-and-push-devcontainer-image:
containers:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- kind: gnu
compilers:
- kind: gcc
version: 14
- kind: llvm
- kind: gcc
version: 13
- kind: gcc
version: 12
- kind: gcc
version: 11
- kind: clang
version: 21
- kind: clang
version: 20
- kind: clang
version: 19
name: "devcontainer: ${{ matrix.kind }}-${{ matrix.version }}"
- kind: clang
version: 18
- kind: clang
version: 17
usage: [dev, test]
name: "${{ matrix.usage }}: ${{ matrix.compilers.kind }}-${{ matrix.compilers.version }}"
steps:
- name: Compute Image Name
id: image_name
run: |
image_name=${{ env.DEPLOY_IMAGE_NAME }}
if [ "${{ github.repository }}/${{ github.ref }}" != "bemanproject/infra/refs/heads/main" ]; then
image_name=${{ env.DEBUG_IMAGE_NAME }}
image_name="${{ env.DEBUG_NAME }}"
tag="${{ matrix.usage }}-${{ matrix.compilers.kind }}-${{ matrix.compilers.version }}"
else
if [ "${{ matrix.usage }}" = "dev" ]; then
image_name="${{ env.DEPLOY_DEV_NAME_PREFIX }}-${{ matrix.compilers.kind }}"
else
image_name="${{ env.DEPLOY_TESTING_NAME_PREFIX }}-${{ matrix.compilers.kind }}"
fi
tag="${{ matrix.compilers.version }}"
fi
echo "computed image name: $image_name"

echo "Image Name: $image_name, Tag: $tag"

echo "image_name=$image_name" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Compute Image base
id: image_base
run: |
if [ "${{ matrix.usage }}" == "dev" ]; then
echo "image=${{ env.BASE_IMAGE_DEV }}" >> "$GITHUB_OUTPUT"
else
echo "image=${{ env.BASE_IMAGE_TEST }}" >> "$GITHUB_OUTPUT"
fi
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
Expand All @@ -50,11 +86,12 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: devcontainer
context: containers
build-args: |
compiler_kind=${{ matrix.kind }}
compiler_version=${{ matrix.version }}
base_image=${{ steps.image_base.outputs.image }}
compiler_kind=${{ matrix.compilers.kind }}
compiler_version=${{ matrix.compilers.version }}
push: true
tags: ${{ env.REGISTRY }}/${{ steps.image_name.outputs.image_name }}:${{ matrix.kind }}-${{ matrix.version }}
tags: ${{ env.REGISTRY }}/${{ steps.image_name.outputs.image_name }}:${{ steps.image_name.outputs.tag }}
# https://github.com/docker/build-push-action/issues/894
Comment on lines 87 to 96
Copy link
Member Author

Choose a reason for hiding this comment

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

Let's move this all in a python script in the next iteration.

provenance: false
37 changes: 37 additions & 0 deletions containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

ARG base_image=mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
FROM ${base_image}

# Create the vscode user
RUN bash <<EOF
if ! id "vscode" &>/dev/null; then
apt-get update && apt-get install -y sudo adduser
useradd -ms /bin/bash -p "" vscode && usermod -aG sudo vscode
fi
EOF

USER vscode
WORKDIR /tmp

COPY install_sys.sh .
RUN bash install_sys.sh

# Newer gcc/ clang is needed to avoid ASAN Stalling, which is turned on by default across beman projects.
# See: https://github.com/google/sanitizers/issues/1614
# Minimal version: clang-18.1.3, gcc-13.2
ARG compiler_kind=gcc
ARG compiler_version=14

COPY install_compiler.sh .
RUN bash install_compiler.sh ${compiler_kind} ${compiler_version}

# Common dependency: google-test
RUN sudo apt-get install -y libgtest-dev

# Pre-commit is beman library's standard linting tool
RUN sudo apt-get install -y pipx
RUN pipx install pre-commit
ENV PATH="/home/vscode/.local/bin:${PATH}"

ENTRYPOINT ["/usr/bin/bash"]
27 changes: 15 additions & 12 deletions devcontainer/README.md → containers/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# Devcontainer
# Containers

<!-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -->

This folder contains the infrastructure for Beman project's
generic devcontainer image. You can checkout available images in beman's
[GitHub Packages page](https://github.com/orgs/bemanproject/packages/container/package/devcontainers).
generic container images. You can checkout available images in beman's
[GitHub Packages page](https://github.com/orgs/bemanproject/packages).

The image is build on top of GitHub's
[C++ devcontainer image](https://github.com/devcontainers/images/tree/main/src/cpp)
for Ubuntu 24.04.

The image includes:
These images includes:

- The latest CMake from kitware's apt repository
- Latest compiler based on build args (gnu or llvm) installed from the universe repository
- Latest compiler based on build args (gcc or clang) installed from the universe repository
- [pre-commit](https://pre-commit.com/), the standard linter manager across Beman

## Example devcontainer setup

## Devcontainer

The image is build on top of GitHub's
[C++ devcontainer image](https://github.com/devcontainers/images/tree/main/src/cpp)
for Ubuntu 24.04.

### Example devcontainer setup

```json
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
{
"name": "Beman Generic Devcontainer",
"image": "ghcr.io/bemanproject/devcontainers:gnu-14",
"image": "ghcr.io/bemanproject/devcontainers-gcc:14",
"postCreateCommand": "pre-commit",
"customizations": {
"vscode": {
Expand All @@ -35,7 +38,7 @@ The image includes:
}
```

## Building your own image
### Building your own image

You can build your own Beman devcontainer image with:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@ VERSION=$2
echo "Install ${TOOL} at: ${VERSION}"

shopt -s nocasematch
if [ "$TOOL" = "gnu" ]; then
if [ "$TOOL" = "gcc" ]; then
sudo apt-get remove -y gcc-"$VERSION" g++-"$VERSION" gcc g++
sudo apt-get install -y gcc-"$VERSION" g++-"$VERSION"
sudo apt-get install -y gcc-"$VERSION" g++-"$VERSION" lcov

sudo rm -f /usr/bin/gcc
sudo rm -f /usr/bin/g++
sudo rm -f /usr/bin/gcov

sudo ln -s "$(which gcc-"$VERSION")" /usr/bin/gcc
sudo ln -s "$(which g++-"$VERSION")" /usr/bin/g++
sudo ln -s "$(which gcov-"$VERSION")" /usr/bin/gcov

gcc --version
else
sudo apt-get install -y lsb-release wget software-properties-common gnupg
wget https://apt.llvm.org/llvm.sh

sudo bash llvm.sh "${VERSION}"
sudo apt-get install -y libc++-"$VERSION"-dev lcov

sudo rm -f /usr/bin/clang
sudo rm -f /usr/bin/clang++
Expand All @@ -34,3 +37,4 @@ else

clang --version
fi

10 changes: 10 additions & 0 deletions containers/install_sys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Install Basic utilities
sudo apt-get install -y ca-certificates gpg wget git curl

# Install Latest CMake
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
sudo apt-get update && sudo apt-get install -y cmake

# Install Ninja
sudo apt-get install -y ninja-build
33 changes: 0 additions & 33 deletions devcontainer/Dockerfile

This file was deleted.