Skip to content

Commit b85c6c1

Browse files
authored
Merge pull request #606 from kaiii708/enhance-docker
Enhance docker image
2 parents 6fd635b + e5e97c8 commit b85c6c1

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

Dockerfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
FROM alpine:3.21 AS base_gcc
22

3-
RUN apk add --update alpine-sdk git wget sdl2-dev sdl2_mixer-dev
3+
RUN apk add --update alpine-sdk git wget sdl2-dev sdl2_mixer-dev dtc
44

55
# copy in the source code
66
WORKDIR /home/root/rv32emu
77
COPY . .
88

9-
# generate execution file for rv32emu and rv_histogram
10-
RUN make
11-
RUN make tool
9+
# build and rename executables: rv32emu-user, rv32emu-system, and rv32emu-histogram
10+
RUN make -j"$(nproc)"
11+
RUN make tool -j"$(nproc)"
12+
RUN mv ./build/rv32emu ./build/rv32emu-user
13+
RUN mv ./build/rv_histogram ./build/rv32emu-histogram
14+
RUN make distclean
15+
RUN make ENABLE_SYSTEM=1 INITRD_SIZE=32 -j"$(nproc)"
1216

13-
FROM alpine:3.19 AS final
17+
FROM alpine:3.21 AS final
1418

1519
# copy in elf files
1620
COPY ./build/*.elf /home/root/rv32emu/build/
1721

1822
# get rv32emu and rv_histogram binaries and lib of SDL2 and SDL2_mixer
1923
COPY --from=base_gcc /usr/include/SDL2/ /usr/include/SDL2/
2024
COPY --from=base_gcc /usr/lib/libSDL2* /usr/lib/
21-
COPY --from=base_gcc /home/root/rv32emu/build/rv32emu /home/root/rv32emu/build/rv32emu
22-
COPY --from=base_gcc /home/root/rv32emu/build/rv_histogram /home/root/rv32emu/build/rv_histogram
25+
COPY --from=base_gcc /home/root/rv32emu/build/rv32emu-user /home/root/rv32emu/build/rv32emu-user
26+
COPY --from=base_gcc /home/root/rv32emu/build/rv32emu /home/root/rv32emu/build/rv32emu-system
27+
COPY --from=base_gcc /home/root/rv32emu/build/rv32emu-histogram /home/root/rv32emu/build/rv32emu-histogram
2328

2429
ENV PATH=/home/root/rv32emu/build:$PATH
2530

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,40 @@ The usage and limitations of Doom and Quake demo are listed in [docs/demo.md](do
143143
### Docker image
144144
The image containing all the necessary tools for development and testing can be executed by `docker run -it sysprog21/rv32emu:latest`. It works for both x86-64 and aarch64 (e.g., Apple's M1 chip) machines.
145145
146+
To keep the Docker image minimal, executables and prebuilt images are not embedded. Follow the steps below to fetch the required artifacts.
147+
148+
##### User-Mode
149+
Fetch and extract the latest prebuilt user-mode ELF artifacts:
150+
```shell
151+
$ wget $(wget -qO- 'https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases?per_page=100' \
152+
| grep browser_download_url | grep ELF | head -n 1 | cut -d '"' -f4)
153+
154+
$ tar -xzvf rv32emu-prebuilt.tar.gz
155+
```
156+
To run `rv32emu-user`, consider the following examples:
157+
```shell
158+
# Run a local ELF program
159+
build/rv32emu-user build/hello.elf
160+
161+
# Run a prebuilt user-mode program (e.g., pi)
162+
build/rv32emu-user rv32emu-prebuilt/riscv32/pi
163+
```
164+
165+
##### System-Mode
166+
Fetch and extract the latest prebuilt system-mode Linux image artifacts:
167+
```shell
168+
$ wget $(wget -qO- 'https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases?per_page=100' \
169+
| grep browser_download_url | grep Linux-Image | head -n 1 | cut -d '"' -f4)
170+
171+
$ tar -xzvf rv32emu-linux-image-prebuilt.tar.gz
172+
```
173+
To run `rv32emu-system`, use the following:
174+
```shell
175+
$ build/rv32emu-system \
176+
-k rv32emu-linux-image-prebuilt/linux-image/Image \
177+
-i rv32emu-linux-image-prebuilt/linux-image/rootfs.cpio
178+
```
179+
146180
### Customization
147181
`rv32emu` is configurable, and you can override the below variable(s) to fit your expectations:
148182
* `ENABLE_RV32E`: RV32E Base Integer Instruction Set

0 commit comments

Comments
 (0)