Skip to content

Commit c8442e8

Browse files
authored
Merge pull request #5 from grivera64/feature/add-docker-build-options
🔥 Feature: Add docker build options
2 parents 1e9cf7e + 14632cc commit c8442e8

File tree

5 files changed

+82
-1
lines changed

5 files changed

+82
-1
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
doc/
3+
Dockerfile*

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM ubuntu:24.04
2+
3+
# AstraKernel Dockerfile
4+
# ======================
5+
# Run the following to start:
6+
# $ make docker
7+
8+
# 1. Install dependencies
9+
RUN apt-get update && apt-get install -y \
10+
# Install git for cloning
11+
git \
12+
# Install bare-metal ARM essentials
13+
build-essential gcc-arm-none-eabi binutils-arm-none-eabi \
14+
qemu-system-arm \
15+
# Clear apt cache
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
# 2. Clone the most recent version of the main branch
19+
WORKDIR /
20+
RUN git clone --single-branch -b main --depth=1 https://github.com/sandbox-science/AstraKernel.git
21+
WORKDIR /AstraKernel
22+
23+
# 3. Build/Run via QEMU
24+
RUN make kernel.bin
25+
26+
CMD ["make", "qemu"]

Dockerfile.dev

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM ubuntu:24.04
2+
3+
# AstraKernel Dockerfile
4+
# ======================
5+
# Run the following to start:
6+
# $ make docker-dev
7+
8+
# 1. Install dependencies
9+
RUN apt-get update && apt-get install -y \
10+
# Install bare-metal ARM essentials
11+
build-essential gcc-arm-none-eabi binutils-arm-none-eabi \
12+
qemu-system-arm \
13+
# Clear apt cache
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# 2. Copy from local FS
17+
COPY include/ /AstraKernel/include
18+
COPY kernel/ /AstraKernel/kernel
19+
COPY user/ /AstraKernel/user
20+
COPY kernel.ld /AstraKernel
21+
COPY Makefile /AstraKernel
22+
WORKDIR /AstraKernel
23+
24+
# 3. Build/Run via QEMU
25+
RUN make kernel.bin
26+
27+
CMD ["make", "qemu"]

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@ qemu:
5353
@echo "Press Ctrl-A then X to exit QEMU"
5454
@qemu-system-arm -M versatilepb -nographic -kernel $(OUT_DIR)kernel.bin
5555

56-
.PHONY: all clean qemu
56+
docker:
57+
docker build -t "astra-kernel" .
58+
docker run -it --rm "astra-kernel"
59+
60+
docker-dev:
61+
docker build -f Dockerfile.dev -t "astra-kernel-dev" .
62+
docker run -it --rm "astra-kernel-dev"
63+
64+
.PHONY: all clean qemu docker

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Type away, explore, have fun.
2626

2727
## Building
2828

29+
### Native Build
30+
2931
Make sure you have an ARM cross-compiler installed (e.g., `arm-none-eabi-gcc`) and `qemu-system-arm`.
3032

3133
```sh
@@ -37,6 +39,21 @@ make
3739
> `make` will clean, build, and run the kernel in QEMU. You can also run
3840
`make qemu` to run the kernel without cleaning or building it again.
3941

42+
### Docker Build
43+
44+
If you have docker installed, you can also run AstraKernel through a docker container:
45+
46+
```sh
47+
make docker
48+
```
49+
50+
> [!IMPORTANT]
51+
>
52+
> `make docker` will pull from the most recent `main` commit from the upstream repository
53+
> `https://github.com/sanbox-science/AstraKernel.git`.
54+
> If you wish to use a local copy, you can run `make docker-dev`, which will copy all
55+
> local build files into the repository.
56+
4057
## Documentation
4158

4259
For more details about this kernel, refer to the [AstraKernel Documentation](https://github.com/sandbox-science/AstraKernel/blob/main/doc/AstraKernelManual.pdf).

0 commit comments

Comments
 (0)