Spaces:
Paused
Paused
| FROM ubuntu:22.04 | |
| # 1. Install Tools | |
| # 'p7zip-full' is REQUIRED to extract files from the ISO | |
| RUN apt-get update && apt-get install -y \ | |
| g++ make qemu-system-misc opensbi u-boot-qemu wget p7zip-full \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 2. Setup User | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| # 3. DOWNLOAD & EXTRACT ALPINE V3.23 (FIXED) | |
| # We use v3.23 because it is the first version with a Standard RISC-V ISO. | |
| # We extract the 'LTS' kernel (vmlinuz-lts) and rename it to 'vmlinuz' for main.cpp | |
| RUN wget https://dl-cdn.alpinelinux.org/alpine/v3.23/releases/riscv64/alpine-standard-3.23.0-riscv64.iso \ | |
| && 7z x alpine-standard-3.23.0-riscv64.iso boot/vmlinuz-lts boot/initramfs-lts \ | |
| && mv boot/vmlinuz-lts vmlinuz \ | |
| && mv boot/initramfs-lts initramfs \ | |
| && mv alpine-standard-3.23.0-riscv64.iso alpine.iso | |
| # 4. GET BIOS | |
| # Copy OpenSBI firmware so QEMU finds it easily | |
| RUN cp /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf bios.elf | |
| # 5. COMPILE APP | |
| COPY --chown=user main.cpp . | |
| RUN g++ -O3 -pthread main.cpp -o ai_server | |
| EXPOSE 7860 | |
| CMD ["./ai_server"] |