Skip to content

Commit c6f8183

Browse files
committed
Clarified Docker-first setup contract
1 parent 63f6bdd commit c6f8183

4 files changed

Lines changed: 110 additions & 35 deletions

File tree

CONTRIBUTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Thank you for your interest in contributing to ThunderOS! This guide will help y
1515

1616
3. **Set up your environment**
1717
- Follow setup instructions in [docs/source/development.rst](docs/source/development.rst)
18-
- Install RISC-V toolchain and QEMU
19-
- Build and test: `make && make qemu`
18+
- Initialize submodules: `git submodule update --init --recursive`
19+
- Run the authoritative verification path first: `make docker-verify`
20+
- Use native `make`, `make qemu`, and `make debug` only after the Docker path is understood
2021

2122
## How to Contribute
2223

@@ -64,8 +65,15 @@ Thank you for your interest in contributing to ThunderOS! This guide will help y
6465
- Target the current `dev/vX.Y.Z` branch
6566
- Write a clear PR description
6667
- Reference related issues
68+
- Include the verification command you ran (`make docker-verify`, or explain why a narrower check was necessary)
6769
- Wait for review
6870

71+
### Working With The Userland Submodule
72+
73+
- `external/userland/` is versioned by the submodule commit recorded in this repository.
74+
- If your change requires userland work, commit and push the `thunderos-userland` change first, then update the submodule pointer here intentionally.
75+
- Before opening a PR that touches the submodule pointer, verify with `make docker-verify` from the ThunderOS root.
76+
6977
## AI Usage Policy
7078

7179
ThunderOS uses AI assistance for development. See the [ai-dev-prompts](https://github.com/byteshiftlabs/ai-dev-prompts) repository for guidelines on:

Makefile

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ QEMU_FLAGS := -machine virt -m 128M -nographic -serial mon:stdio
111111
QEMU_FLAGS += -bios none
112112
QEMU_FLAGS += $(QEMU_ACCEL_FLAGS)
113113
QEMU_FLAGS += $(QEMU_EXTRA_FLAGS)
114+
DOCKER_IMAGE ?= thunderos-build:local
115+
DOCKER_USER ?= $(shell id -u):$(shell id -g)
114116

115117
# Filesystem image
116118
FS_IMG := $(BUILD_DIR)/fs.img
117119
FS_SIZE := 10M
118120

119-
.PHONY: all clean run debug fs userland test test-quick help
121+
.PHONY: all clean run debug fs userland test test-quick help docker-build-env docker-verify docker-shell
120122

121123
# Default target - must be first
122124
all: $(KERNEL_ELF) $(KERNEL_BIN)
@@ -145,6 +147,9 @@ help:
145147
@echo " $(GREEN)make clean$(RESET) Remove all build artifacts"
146148
@echo " $(GREEN)make userland$(RESET) Build userland programs only"
147149
@echo " $(GREEN)make fs$(RESET) Build ext2 filesystem image"
150+
@echo " $(GREEN)make docker-build-env$(RESET) Build the authoritative Docker toolchain image"
151+
@echo " $(GREEN)make docker-verify$(RESET) Run clean build + test inside the Docker image"
152+
@echo " $(GREEN)make docker-shell$(RESET) Open an interactive shell inside the Docker image"
148153
@echo ""
149154
@echo "$(BOLD)Run Targets:$(RESET)"
150155
@echo " $(GREEN)make run$(RESET) Build and run in QEMU (text mode)"
@@ -296,6 +301,37 @@ test:
296301
test-quick:
297302
@cd tests/scripts && bash test_runner.sh --quick
298303

304+
docker-build-env:
305+
@echo ""
306+
@echo "$(BOLD)$(BLUE)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$(RESET)"
307+
@echo "$(BOLD)$(BLUE) Building ThunderOS Docker Environment$(RESET)"
308+
@echo "$(BOLD)$(BLUE)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$(RESET)"
309+
@docker build -t $(DOCKER_IMAGE) .
310+
@echo "$(GREEN)✓ Docker image ready:$(RESET) $(DOCKER_IMAGE)"
311+
@echo ""
312+
313+
docker-verify: docker-build-env
314+
@echo ""
315+
@echo "$(BOLD)$(GREEN)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$(RESET)"
316+
@echo "$(BOLD)$(GREEN) Running Authoritative Docker Verification$(RESET)"
317+
@echo "$(BOLD)$(GREEN)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$(RESET)"
318+
@docker run --rm \
319+
--user $(DOCKER_USER) \
320+
-e HOME=/tmp/thunderos-home \
321+
-v $(CURDIR):/workspace \
322+
-w /workspace \
323+
$(DOCKER_IMAGE) \
324+
bash -lc "make clean && make && make test"
325+
326+
docker-shell: docker-build-env
327+
@docker run --rm -it \
328+
--user $(DOCKER_USER) \
329+
-e HOME=/tmp/thunderos-home \
330+
-v $(CURDIR):/workspace \
331+
-w /workspace \
332+
$(DOCKER_IMAGE) \
333+
bash
334+
299335
qemu: userland fs
300336
@rm -f $(BUILD_DIR)/kernel/main.o
301337
@$(MAKE) --no-print-directory TEST_MODE=0 all

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@ See [CHANGELOG.md](CHANGELOG.md) for complete feature list and [ROADMAP.md](ROAD
1919
### Cloning
2020
```bash
2121
git clone --recurse-submodules https://github.com/byteshiftlabs/thunderos.git
22+
cd thunderos
23+
git submodule update --init --recursive
2224
```
2325

26+
### Authoritative Verification
27+
```bash
28+
make docker-verify
29+
```
30+
31+
This is the release-grade setup path. It builds the repository Docker image, uses the pinned RISC-V toolchain and QEMU 10.1.2 from that image, and runs `make clean && make && make test` inside the container.
32+
2433
### Building
2534
```bash
2635
make clean && make
@@ -36,7 +45,7 @@ make OPT_LEVEL=-O2 DEBUG_SYMBOLS=1
3645
make qemu
3746
```
3847

39-
The OS will automatically build the filesystem image and start QEMU with VirtIO block device support.
48+
The OS will automatically build the filesystem image and start QEMU with VirtIO block device support. Native QEMU runs are a convenience path for local iteration; if your host toolchain or QEMU version differs from the Docker environment, use `make docker-verify` before treating the result as release-quality.
4049

4150
For smoother local runs, you can override QEMU acceleration and extra flags:
4251
```bash
@@ -64,6 +73,27 @@ riscv64-unknown-elf-gdb build/thunderos.elf
6473
(gdb) target remote :1234
6574
```
6675

76+
If your host toolchain does not match the Docker-verified environment, open the authoritative shell first and debug from there:
77+
78+
```bash
79+
make docker-shell
80+
```
81+
82+
## Setup Contract
83+
84+
ThunderOS has two supported public setup paths:
85+
86+
1. `make docker-verify`
87+
This is the authoritative verification path used to mirror release gating. It relies on the repository Dockerfile, which pins the RISC-V bare-metal toolchain and QEMU 10.1.2.
88+
2. `make`, `make qemu`, `make debug`
89+
This is the native Linux convenience path for day-to-day development when you already have a matching toolchain, `mkfs.ext2`, and QEMU 10.1.2+ on the host.
90+
91+
If the native host path disagrees with Docker, Docker wins.
92+
93+
## Versioning And Userland
94+
95+
`external/userland/` is pinned by git submodule commit, not by a floating branch. Releases are expected to update that submodule intentionally, keep `git submodule status` clean, and pass `make docker-verify` before publishing. That is the contract that keeps kernel and userland changes versioned together.
96+
6797
## Documentation
6898

6999
Full technical documentation is available in Sphinx format:
@@ -145,7 +175,10 @@ Programs are compiled as RISC-V ELF64 executables and can be loaded from the ext
145175

146176
## Platform Support
147177

148-
- **QEMU virt machine**: Tested and working ✓
178+
- **Runtime target**: QEMU `virt` machine with 128 MiB RAM, `-bios none`, and VirtIO block storage
179+
- **Authoritative verification environment**: Repository Dockerfile with the pinned RISC-V toolchain and QEMU 10.1.2
180+
- **Native host development**: Supported as a convenience path when the host matches the documented toolchain requirements
181+
- **Real hardware**: Not a supported public target yet; bring-up work should be treated as experimental until documented otherwise
149182

150183
## Requirements
151184

docs/source/development.rst

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,38 @@ Building
88
Prerequisites
99
~~~~~~~~~~~~~
1010

11-
**Option 1: Using Docker (Recommended)**
11+
**Option 1: Using Docker (Authoritative Verification Path)**
1212

13-
The easiest way to build ThunderOS is using Docker, which provides a consistent build environment:
13+
The repository Dockerfile is the authoritative release-verification environment. It provides the pinned RISC-V bare-metal toolchain, QEMU 10.1.2, and the documentation dependencies used by CI.
1414

1515
.. code-block:: bash
1616
17-
# Build the Docker image
18-
docker build -t thunderos-build .
19-
20-
# Build ThunderOS in Docker
21-
docker run --rm -v $(pwd):/workspace -w /workspace thunderos-build make all
22-
23-
# Run in QEMU via Docker
24-
docker run --rm -v $(pwd):/workspace -w /workspace thunderos-build make qemu
17+
make docker-verify
2518
26-
**Option 2: Native Installation (Ubuntu/Debian)**
19+
For an interactive shell inside that same environment:
2720

2821
.. code-block:: bash
2922
30-
# QEMU (for emulation)
31-
sudo apt-get install qemu-system-misc
32-
33-
# Build tools
34-
sudo apt-get install build-essential make wget
35-
36-
# RISC-V toolchain (manual installation required)
37-
# Download from SiFive or build from source
38-
wget https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
39-
tar -xzf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
40-
sudo mv riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14 /opt/riscv
41-
export PATH="/opt/riscv/bin:$PATH" # Add to ~/.bashrc
42-
43-
# Verify installation
23+
make docker-shell
24+
25+
**Option 2: Native Linux Convenience Path**
26+
27+
Native builds are intended for day-to-day development once you already have a matching toolchain installed. If native behavior disagrees with Docker, treat Docker as authoritative.
28+
29+
.. code-block:: bash
30+
31+
git submodule update --init --recursive
4432
riscv64-unknown-elf-gcc --version
4533
qemu-system-riscv64 --version
34+
make clean && make
35+
make test
36+
37+
The native path requires:
38+
39+
- ``riscv64-unknown-elf-gcc`` on ``PATH``
40+
- ``qemu-system-riscv64`` 10.1.2 or newer
41+
- ``mkfs.ext2`` from ``e2fsprogs``
42+
- standard Unix build tools (``make``, ``bash``, ``sed``)
4643

4744
**Option 3: Using Build Scripts (After Setup)**
4845

@@ -58,7 +55,7 @@ Once prerequisites are installed:
5855
Compilation
5956
~~~~~~~~~~~
6057

61-
**Using Build Scripts (Recommended)**
58+
**Using Build Scripts (Native Convenience Path)**
6259

6360
.. code-block:: bash
6461
@@ -82,6 +79,9 @@ Compilation
8279
# Debug with GDB
8380
make debug
8481
82+
# Authoritative Docker verification
83+
make docker-verify
84+
8585
Testing
8686
-------
8787

@@ -129,10 +129,8 @@ To run similar tests locally:
129129

130130
.. code-block:: bash
131131
132-
# Build and test (mimics CI)
133-
docker build -t thunderos-build .
134-
docker run --rm -v $(pwd):/workspace -w /workspace thunderos-build make clean && make
135-
docker run --rm -v $(pwd):/workspace -w /workspace thunderos-build make test
132+
# Build and test through the same Docker image used for release verification
133+
make docker-verify
136134
137135
138136
Debugging

0 commit comments

Comments
 (0)