Skip to content
Merged
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
18 changes: 18 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

# Fetch latest versions of CMake and Catch2
- name: Get latest CMake version
id: cmake_version
run: |
CMAKE_VERSION=$(curl -s https://api.github.com/repos/Kitware/CMake/releases/latest | jq -r '.tag_name')
echo "version=$CMAKE_VERSION" >> $GITHUB_OUTPUT
echo "Latest CMake version: $CMAKE_VERSION"

- name: Get latest Catch2 version
id: catch2_version
run: |
CATCH2_VERSION=$(curl -s https://api.github.com/repos/catchorg/Catch2/releases/latest | jq -r '.tag_name')
echo "version=$CATCH2_VERSION" >> $GITHUB_OUTPUT
echo "Latest Catch2 version: $CATCH2_VERSION"

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
Expand Down Expand Up @@ -82,6 +97,9 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
CMAKE_VERSION=${{ steps.cmake_version.outputs.version }}
CATCH2_VERSION=${{ steps.catch2_version.outputs.version }}

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
Expand Down
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
FROM gcc:latest

# Build arguments for versions (with defaults for backward compatibility)
ARG CMAKE_VERSION=v4.0.3
ARG CATCH2_VERSION=v3.8.1

# Set the working directory
WORKDIR /app

# Install CMake
RUN apt-get update && apt-get install -y wget && \
ARCH=$(uname -m) && \
CMAKE_VER_NO_V=${CMAKE_VERSION#v} && \
if [ "$ARCH" = "aarch64" ]; then \
wget -q https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3-linux-aarch64.sh; \
wget -q https://github.com/Kitware/CMake/releases/download/${CMAKE_VERSION}/cmake-${CMAKE_VER_NO_V}-linux-aarch64.sh; \
else \
wget -q https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3-linux-x86_64.sh; \
wget -q https://github.com/Kitware/CMake/releases/download/${CMAKE_VERSION}/cmake-${CMAKE_VER_NO_V}-linux-x86_64.sh; \
fi && \
chmod +x cmake-4.0.3-linux-*.sh && \
./cmake-4.0.3-linux-*.sh --skip-license --prefix=/usr/local && \
chmod +x cmake-${CMAKE_VER_NO_V}-linux-*.sh && \
./cmake-${CMAKE_VER_NO_V}-linux-*.sh --skip-license --prefix=/usr/local && \
ln -s /usr/local/bin/cmake /usr/bin/cmake

# Install Catch2
RUN wget -q https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.1.zip && \
unzip v3.8.1.zip && \
cd Catch2-3.8.1 && \
RUN CATCH2_VER_NO_V=${CATCH2_VERSION#v} && \
wget -q https://github.com/catchorg/Catch2/archive/refs/tags/${CATCH2_VERSION}.zip && \
unzip ${CATCH2_VERSION}.zip && \
cd Catch2-${CATCH2_VER_NO_V} && \
cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
cmake --build build/ --target install

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ To build the image locally, run the following command:
docker build -t cpp-runner .
```

### Building with specific versions

The image automatically uses the latest releases of CMake and Catch2 when built through GitHub Actions. For local builds, you can specify versions using build arguments:

```bash
# Build with specific versions
docker build --build-arg CMAKE_VERSION=v3.29.0 --build-arg CATCH2_VERSION=v3.7.1 -t cpp-runner .

# Build with default versions (same as just docker build -t cpp-runner .)
docker build --build-arg CMAKE_VERSION=v4.0.3 --build-arg CATCH2_VERSION=v3.8.1 -t cpp-runner .
```

The GitHub Actions workflow automatically fetches and uses the latest released versions of both dependencies.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.