Skip to content

Commit

Permalink
Merge pull request #321 from henrybear327/ci/reduce_docker_image_size
Browse files Browse the repository at this point in the history
CI: Generate Docker image with Alpine Linux
  • Loading branch information
jserv authored Jan 6, 2024
2 parents 664f90d + 49778e4 commit e2eb61a
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
FROM sysprog21/rv32emu-sail as base_sail
FROM alpine:3.19 as base_gcc

FROM ubuntu:22.04 as base_gcc

# install extra packages for the emulator to compile with full capabilities correctly
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential curl git && \
rm -rf /var/lib/apt/lists/*
RUN apk add --update alpine-sdk git curl

# copy in the source code
WORKDIR /home/root/rv32emu
COPY . .

# generate execution file for rv32emu and rv_histogram
RUN make
RUN make ENABLE_SDL=0
RUN make tool

FROM ubuntu:22.04 as final

# set up the timezone
ENV TZ=Asia/Taipei
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
FROM alpine:3.19 as final

# copy in elf files and reference emulator
WORKDIR /home/root/rv32emu
# copy in elf files
COPY ./build/*.elf /home/root/rv32emu/build/
COPY ./tests/arch-test-target/sail_cSim/riscv_sim_RV32 /home/root/rv32emu/tests/arch-test-target/sail_cSim/

# replace the emulator (riscv_sim_RV32) with the arch that the container can execute
RUN rm /home/root/rv32emu/tests/arch-test-target/sail_cSim/riscv_sim_RV32
COPY --from=base_sail /home/root/riscv_sim_RV32 /home/root/rv32emu/tests/arch-test-target/sail_cSim/

# get rv32emu and rv_histogram binaries
COPY --from=base_gcc /home/root/rv32emu/build/rv32emu /home/root/rv32emu/build/rv32emu
COPY --from=base_gcc /home/root/rv32emu/build/rv_histogram /home/root/rv32emu/build/rv_histogram

ENV PATH=/home/root/rv32emu/build:/home/root/rv32emu/tests/arch-test-target/sail_cSim:$PATH
ENV PATH=/home/root/rv32emu/build:$PATH

WORKDIR /home/root/rv32emu

0 comments on commit e2eb61a

Please sign in to comment.