Skip to content

Commit 416a2a2

Browse files
Ravenwaterclaude
andcommitted
fix(docker): make release image a usable dev environment
Replace the multi-stage build-artifacts-only image with a single-stage development image that has gcc, clang, cmake, gdb, and the Universal headers installed to /usr/local. Users can write, compile, and run C++ programs using Universal directly inside the container. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent deb5f4b commit 416a2a2

File tree

5 files changed

+55
-55
lines changed

5 files changed

+55
-55
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ jobs:
120120
with:
121121
context: .
122122
file: docker/Dockerfile.release
123-
target: release
124123
push: true
125124
tags: ${{ steps.meta.outputs.tags }}
126125
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,21 @@ A quick description of the structure of the number system parameterization can b
121121

122122
## Quick start
123123

124-
If you just want to experiment with the number system tools and test suites and don't want to bother cloning and building the source code, there is a Docker container to get started:
124+
If you just want to experiment with Universal without cloning and building the source code, there is a Docker container with compilers, cmake, and the library pre-installed:
125125

126126
```text
127127
> docker pull stillwater/universal
128128
> docker run -it --rm stillwater/universal bash
129-
stillwater@b3e6708fd732:~/universal/build$ ls
130-
CMakeCache.txt Makefile cmake-uninstall.cmake playground universal-config-version.cmake
131-
CMakeFiles applications cmake_install.cmake tests universal-config.cmake
132-
CTestTestfile.cmake c_api education tools universal-targets.cmake
129+
stillwater@container:~$ ieee 1.5
130+
stillwater@container:~$ cat > hello.cpp << 'EOF'
131+
#include <universal/number/posit/posit.hpp>
132+
#include <iostream>
133+
int main() {
134+
sw::universal::posit<16,2> p = 1.5;
135+
std::cout << p << '\n';
136+
}
137+
EOF
138+
stillwater@container:~$ g++ -std=c++20 -I/usr/local/include/sw -o hello hello.cpp && ./hello
133139
```
134140

135141
[Here](docs/command-line-tools.md) is a quick reference of what the command line tools have to offer.

docker/Dockerfile.release

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,48 @@
1-
# Self-contained multi-stage release Dockerfile for Universal Numbers Library.
2-
# No dependency on pre-built stillwater/builders:* images.
1+
# Universal Numbers Library — development image for Docker Hub.
2+
#
3+
# Provides a ready-to-use C++ development environment with the Universal
4+
# library installed, compilers, cmake, and command-line inspection tools.
35
#
46
# Usage:
5-
# docker build --target release -t stillwater/universal:latest -f docker/Dockerfile.release .
6-
# docker run --rm stillwater/universal:latest ieee 1.5
7-
8-
ARG BUILD_TARGET=UNIVERSAL_BUILD_ALL
9-
10-
# ---------------------------------------------------------------------------
11-
# Builder stage
12-
# ---------------------------------------------------------------------------
13-
FROM ubuntu:24.04 AS builder
7+
# docker build -t stillwater/universal:latest -f docker/Dockerfile.release .
8+
# docker run -it --rm stillwater/universal bash
9+
#
10+
# Then inside the container:
11+
# cat > hello.cpp << 'EOF'
12+
# #include <universal/number/posit/posit.hpp>
13+
# #include <iostream>
14+
# int main() {
15+
# sw::universal::posit<16,2> p = 1.5;
16+
# std::cout << p << '\n';
17+
# }
18+
# EOF
19+
# g++ -std=c++20 -I/usr/local/include/sw -o hello hello.cpp && ./hello
20+
21+
FROM ubuntu:24.04
1422

1523
RUN apt-get update \
1624
&& apt-get install -y --no-install-recommends \
1725
build-essential \
26+
clang \
1827
cmake \
1928
ninja-build \
29+
gdb \
30+
git \
2031
ca-certificates \
2132
&& apt-get clean && rm -rf /var/lib/apt/lists/*
2233

23-
RUN useradd -ms /bin/bash stillwater
24-
USER stillwater
25-
26-
COPY --chown=stillwater:stillwater . /home/stillwater/universal
27-
WORKDIR /home/stillwater/universal
28-
29-
ARG BUILD_TARGET
30-
RUN cmake -B build -G Ninja \
34+
# Copy source, build command-line tools, install headers + tools to /usr/local
35+
COPY . /tmp/universal-src
36+
RUN cmake -S /tmp/universal-src -B /tmp/universal-build -G Ninja \
3137
-DCMAKE_BUILD_TYPE=Release \
32-
-D${BUILD_TARGET}=ON \
33-
-DUNIVERSAL_BUILD_CMD_LINE_TOOLS=ON \
34-
-DUNIVERSAL_BUILD_DEMONSTRATION=OFF \
35-
&& cmake --build build -j$(nproc)
36-
37-
# ---------------------------------------------------------------------------
38-
# Release stage — minimal image with pre-built binaries
39-
# ---------------------------------------------------------------------------
40-
FROM ubuntu:24.04 AS release
38+
-DUNIVERSAL_BUILD_TOOLS_CMD_LINE=ON \
39+
&& cmake --build /tmp/universal-build -j$(nproc) \
40+
&& cmake --install /tmp/universal-build --prefix /usr/local \
41+
&& rm -rf /tmp/universal-src /tmp/universal-build
4142

4243
RUN useradd -ms /bin/bash stillwater
4344
USER stillwater
44-
45-
COPY --from=builder /usr/bin/cmake /usr/local/bin/
46-
COPY --from=builder /usr/bin/ctest /usr/local/bin/
47-
COPY --from=builder /home/stillwater/universal/*.md /home/stillwater/universal/
48-
COPY --chown=stillwater:stillwater --from=builder \
49-
/home/stillwater/universal/docs /home/stillwater/universal/docs
50-
COPY --chown=stillwater:stillwater --from=builder \
51-
/home/stillwater/universal/build /home/stillwater/universal/build
52-
53-
# Expose command-line tools on PATH
54-
COPY --from=builder /home/stillwater/universal/build/tools/cmd/* /usr/local/bin/
55-
56-
WORKDIR /home/stillwater/universal/build
45+
WORKDIR /home/stillwater
5746

5847
ENV CONTAINER_ID="Universal Number Systems Container"
5948
CMD ["/usr/bin/env", "bash"]

docker/build-release.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ VERSION=$(git -C "$ROOT_DIR" describe --tags --abbrev=0 2>/dev/null || \
1818
echo "Building $REPO:$VERSION"
1919

2020
docker build \
21-
--target release \
2221
-t "$REPO:$VERSION" \
2322
-t "$REPO:latest" \
2423
-f "$SCRIPT_DIR/Dockerfile.release" \

docs-site/src/content/docs/getting-started/docker.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,27 @@ sidebar:
55
order: 2
66
---
77

8-
If you want to experiment with Universal's number system tools and test suites without cloning and building the source code, use the Docker container:
8+
The Docker image provides a ready-to-use C++ development environment with compilers, cmake, the Universal library headers pre-installed, and command-line inspection tools on the PATH.
99

1010
```bash
1111
docker pull stillwater/universal
1212
docker run -it --rm stillwater/universal bash
1313
```
1414

15-
Once inside the container, all tools and test executables are pre-built and ready to use:
15+
Write and compile programs using Universal directly inside the container:
1616

17-
```text
18-
stillwater@b3e6708fd732:~/universal/build$ ls
19-
CMakeCache.txt Makefile cmake-uninstall.cmake playground universal-config-version.cmake
20-
CMakeFiles applications cmake_install.cmake tests universal-config.cmake
21-
CTestTestfile.cmake c_api education tools universal-targets.cmake
17+
```cpp
18+
// hello.cpp
19+
#include <universal/number/posit/posit.hpp>
20+
#include <iostream>
21+
int main() {
22+
sw::universal::posit<16,2> p = 1.5;
23+
std::cout << p << '\n';
24+
}
25+
```
26+
27+
```bash
28+
g++ -std=c++20 -I/usr/local/include/sw -o hello hello.cpp && ./hello
2229
```
2330

2431
## Try the Command-Line Tools

0 commit comments

Comments
 (0)