Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
58 changes: 45 additions & 13 deletions .github/workflows/build_devcontainer.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,75 @@
# SPDX-License-Identifier: 2.0 license with LLVM exceptions

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
DEPLOY_DEV_IMAGE_NAME: bemanproject/devcontainers
DEPLOY_TESTING_IMAGE_NAME: bemanproject/testing-images
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:
compilers:
- kind: gnu
version: 14
- kind: gnu
version: 13
- kind: gnu
version: 12
- kind: gnu
version: 11
- kind: llvm
version: 20
- kind: llvm
version: 19
name: "devcontainer: ${{ matrix.kind }}-${{ matrix.version }}"
- kind: llvm
version: 18
- kind: llvm
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_IMAGE_NAME }}"
tag="${{ matrix.usage }}-${{ matrix.compilers.kind }}-${{ matrix.compilers.version }}"
else
if [ "${{ matrix.usage }}" = "dev" ]; then
image_name="${{ env.DEPLOY_DEV_IMAGE_NAME }}"
else
image_name="${{ env.DEPLOY_TESTING_IMAGE_NAME }}"
fi
tag="${{ matrix.compilers.kind }}-${{ matrix.compilers.version }}"
fi
echo "computed image name: $image_name"
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 +81,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
22 changes: 13 additions & 9 deletions devcontainer/Dockerfile → containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
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

# Latest CMake needed for most of the beman libraries,
# so we need to install via kitware's apt repo
RUN bash <<EOF
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
EOF
COPY install_sys.sh .
RUN bash install_sys.sh

# Newer gcc/ llvm is needed to avoid ASAN Stalling, which is turned on by default across beman projects.
# See: https://github.com/google/sanitizers/issues/1614
Expand All @@ -22,7 +26,7 @@ ARG compiler_version=14
COPY install_compiler.sh .
RUN bash install_compiler.sh ${compiler_kind} ${compiler_version}

# Needed for recent exemplar
# Common dependency: google-test
RUN sudo apt-get install -y libgtest-dev

# Pre-commit is beman library's standard linting tool
Expand Down
23 changes: 13 additions & 10 deletions devcontainer/README.md → containers/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Devcontainer
# Containers

<!-- SPDX-License-Identifier: 2.0 license with LLVM exceptions -->

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
- [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: 2.0 license with LLVM exceptions
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 @@ -25,6 +25,7 @@ else
wget https://apt.llvm.org/llvm.sh

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

sudo rm -f /usr/bin/clang
sudo rm -f /usr/bin/clang++
Expand All @@ -34,3 +35,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