From 451344f676938e832ed6b0ae1d1e1f795cbef377 Mon Sep 17 00:00:00 2001 From: SingularityKChen Date: Thu, 19 Oct 2023 15:23:53 +0800 Subject: [PATCH] dev: add Dev Container + Update and move Dockerfile to .devcontainer; --- .devcontainer/Dockerfile | 34 +++++++++++++++++++++++ .devcontainer/devcontainer.json | 7 +++++ Makefile | 2 +- docker/Dockerfile | 48 --------------------------------- 4 files changed, 42 insertions(+), 49 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json delete mode 100644 docker/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..48c896f --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,34 @@ +FROM archlinux:latest AS root + +ENV LANG=C.UTF-8 + +RUN pacman -Syu --noconfirm make parallel wget cmake ninja verilator git llvm clang python autoconf automake + +RUN pacman -Syu --noconfirm vim which + +# Install GraalVM Ref: https://github.com/chipsalliance/chisel/blob/86b2a7d3f7807ca0d1d8a725bd87ee4be1f61007/.devcontainer/Dockerfile#L32-L40 +# This downloads all relevant GraalVM architectures at once, mostly because $TARGETARCH values don't map exactly to the release URLs. Since we're optimizing for developer experience here and not image size, this is OK +# GraalVM release links can be found here: https://github.com/graalvm/graalvm-ce-builds/releases +ENV JAVA_VERSION=java11 +#ADD https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-$JAVA_VERSION-linux-aarch64-22.3.1.tar.gz /graalvm/tarballs/arm64.tar.gz +ADD https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-$JAVA_VERSION-linux-amd64-22.3.1.tar.gz /graalvm/tarballs/amd64.tar.gz +#RUN tar -xzf /graalvm/tarballs/$TARGETARCH.tar.gz -C /graalvm --strip-components=1 +RUN tar -xzf /graalvm/tarballs/amd64.tar.gz -C /graalvm --strip-components=1 +ENV JAVA_HOME=/graalvm +ENV PATH=$JAVA_HOME/bin/:$PATH + +# Download and install mill +RUN curl -L https://github.com/com-lihaoyi/mill/releases/download/0.11.5/0.11.5 > mill && \ + chmod +x mill && \ + mv mill /usr/bin/mill + +# ivy development dependencies +RUN cd /tmp && \ + git clone https://github.com/SingularityKChen/chisel-chipware.git +RUN cd /tmp/chisel-chipware && \ + mill -i -j 0 __.compile && \ + mill -i -j 0 __.reformat && \ + cd .. && \ + rm -rf chisel-chipware + +CMD ["/usr/bin/bash"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f1bb1e7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,7 @@ +{ + "name": "ViTA Dev", + "build": { + // Path is relative to the devcontainer.json file. + "dockerfile": "Dockerfile" + } +} diff --git a/Makefile b/Makefile index 97035ea..c0a2ab8 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ doc: utils/mill -j 0 show __.docJar build_docker: - docker build -f docker/Dockerfile -t chisel-chipware:latest . + docker build -f .devcontainer/Dockerfile -t chisel-chipware:latest . run_docker: build_docker docker run -it --rm -v $(shell pwd):/workspace/$(shell basename $$(pwd)) --workdir /workspace/$(shell basename $$(pwd)) chisel-chipware:latest diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 4b84d54..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -# We're using a multistage Docker build here in order to allow us to release a self-verifying -# Docker image when built on the official Docker infrastructure. -# They require us to verify the source integrity in some way while making sure that this is a -# reproducible build. -# See https://github.com/docker-library/official-images#image-build -# In order to achieve this, we externally host the rootfs archives and their checksums and then -# just download and verify it in the first stage of this Dockerfile. -# The second stage is for actually configuring the system a little bit. -# Some templating is done in order to allow us to easily build different configurations and to -# allow us to automate the releaes process. -FROM alpine:3.18 AS verify - -RUN apk add --no-cache curl tar zstd - -# https://gitlab.archlinux.org/archlinux/archlinux-docker/-/releases/v20230709.0.163418 -RUN ROOTFS="$(curl -sOJL -w "%{filename_effective}" "https://gitlab.archlinux.org/archlinux/archlinux-docker/-/package_files/4840/download")" && \ - echo "9d301b49c4ef3174ffbafc781b0cde2741c9b0a2f5451d65abf28d77a281aa3f base-20230709.0.163418.tar.zst" > /tmp/rootfs.tar.sha256 && \ - cat /tmp/rootfs.tar.sha256 && \ - sha256sum -c /tmp/rootfs.tar.sha256 && \ - mkdir /rootfs && \ - tar -C /rootfs --extract --file "${ROOTFS}" - -FROM scratch AS root -COPY --from=verify /rootfs/ / - -RUN ldconfig && \ - sed -i '/BUILD_ID/a VERSION_ID=20230709.0.163418' /etc/os-release - -ENV LANG=C.UTF-8 - -RUN pacman -Syu --noconfirm make parallel wget cmake ninja dtc verilator git llvm clang lld protobuf antlr4 python autoconf automake - -RUN pacman -Syu --noconfirm vim which - -# Download and install mill -RUN curl -L https://github.com/com-lihaoyi/mill/releases/download/0.11.1/0.11.1 > mill && \ - chmod +x mill && \ - mv mill /usr/bin/mill - -# ivy development dependencies -RUN git clone https://github.com/SingularityKChen/chisel-chipware.git && \ - cd chisel-chipware && \ - mill -i -j 0 __.compile && \ - mill -i -j 0 __.reformat && \ - cd .. && \ - rm -rf chisel-chipware - -CMD ["/usr/bin/bash"] \ No newline at end of file