Skip to content

Commit

Permalink
Merge pull request #771 from ucb-bar/update-dockerfiles
Browse files Browse the repository at this point in the history
Update dockerfiles
  • Loading branch information
abejgonzalez authored Feb 21, 2021
2 parents 5966588 + b12fa04 commit a86f801
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 238 deletions.
7 changes: 3 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ parameters:
executors:
main-env:
docker:
- image: ucbbar/chipyard-image:1.0.1
- image: ucbbar/chipyard-ci-image:9c650dea
environment:
JVM_OPTS: -Xmx3200m # Customize the JVM maximum heap limit

Expand Down Expand Up @@ -112,7 +112,7 @@ commands:
default: "run-tests.sh"
timeout:
type: string
default: "10m"
default: "25m"
steps:
- setup-tools:
tools-version: "<< parameters.tools-version >>"
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
- run-tests:
group-key: "group-cores"
project-key: "chipyard-hetero"
timeout: "15m"
timeout: "20m"
chipyard-boom-run-tests:
executor: main-env
steps:
Expand Down Expand Up @@ -520,4 +520,3 @@ workflows:
- prepare-chipyard-fpga:
requires:
- install-riscv-toolchain

216 changes: 0 additions & 216 deletions .circleci/images/Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions .circleci/images/README.md

This file was deleted.

67 changes: 67 additions & 0 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
### This is a full chipyard setup

# BUILD BASE FOR CI

FROM ubuntu:18.04 as base
ARG CHIPYARD_HASH

MAINTAINER https://groups.google.com/forum/#!forum/chipyard

# Install dependencies for ubuntu-req.sh
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
curl \
git \
sudo \
ca-certificates \
keyboard-configuration \
console-setup

# Adds a new user called riscvuser
RUN groupadd --gid 3434 riscvuser \
&& useradd --uid 3434 --gid riscvuser --shell /bin/bash --create-home riscvuser \
&& echo 'riscvuser ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-riscvuser \
&& echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep

WORKDIR /home/riscvuser
USER riscvuser

# Update PATH for RISCV toolchain (note: hardcoded for CircleCI)
ENV RISCV="/home/riscvuser/riscv-tools-install"
ENV LD_LIBRARY_PATH="$RISCV/lib"
ENV PATH="$RISCV/bin:$PATH"

# Install Chipyard and run ubuntu-req.sh to install necessary dependencies
RUN git clone https://github.com/ucb-bar/chipyard.git && \
cd chipyard && \
git checkout $CHIPYARD_HASH && \
./scripts/ubuntu-req.sh 1>/dev/null && \
sudo rm -rf /var/lib/apt/lists/*


# BUILD IMAGE WITH TOOLCHAINS

# Use above build as base
FROM base as base-with-tools

# Init submodules
RUN cd chipyard && \
export MAKEFLAGS=-"j $(nproc)" && \
./scripts/init-submodules-no-riscv-tools.sh 1>/dev/null

# Install riscv-tools
RUN cd chipyard && \
export MAKEFLAGS=-"j $(nproc)" && \
./scripts/build-toolchains.sh riscv-tools 1>/dev/null

# Install esp-tools
RUN cd chipyard && \
export MAKEFLAGS=-"j $(nproc)" && \
./scripts/build-toolchains.sh esp-tools 1>/dev/null

# Run script to set environment variables on entry
ENTRYPOINT ["chipyard/scripts/entrypoint.sh"]

# END IMAGE CUSTOMIZATIONS

CMD ["/bin/sh"]
22 changes: 22 additions & 0 deletions dockerfiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
General
-------
This DockerFile contains the necessary steps to build a Docker container that can run
projects with riscv-tools, chisel3, firrtl, and verilator. When run up to the base stage, it installs the necessary
apt-get packages and sets the environment variables needed for CircleCI. When run up to the base-with-tools stage, it initializes and installs the necessary toolchains for running simulations and testing projects.

Build and Deploy the Container
------------------------------

sudo docker build --target base . # to build the image for the CI
sudo docker build --target base --build-arg CHIPYARD_HASH=<COMMIT_HASH> . # to build the image for the CI from a specific chipyard commit
sudo docker build --target base-with-tools . # to build the full image
sudo docker tag <IMAGE_ID> <PATH_NAME>:tag . # to tag the image after the build (ex. 0.0.3)
sudo docker login # login into the account to push to
sudo docker push <PATH_NAME>:tag # to push to repo with tag
sudo docker run -it <IMAGE_ID> bash # to run an interactive version of the container

Path Names
----------
Older docker images (when this Dockerfile was in `riscv-boom/riscv-boom`) can be found in the <PATH_NAME> `riscvboom/riscvboom-images`.
Current up-to-date images are located in <PATH_NAME> `ucbbar/chipyard-image`. NOTE: Less recent images in this path may not have toolchains initialized
Current up-to-date CI images are located in <PATH_NAME> `ucbbar/chipyard-ci-image`.
16 changes: 16 additions & 0 deletions docs/Chipyard-Basics/Initial-Repo-Setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ You can put this in your ``.bashrc`` or equivalent environment setup file to get
These variables need to be set for the ``make`` system to work properly.

Pre-built Docker Image
-------------------------------------------

An alternative to setting up the Chipyard repository locally is to pull the pre-built Docker image from Docker Hub. The image comes with all dependencies installed, Chipyard cloned, and toolchains initialized. This image sets up baseline Chipyard (not including FireMarshal, FireSim, and Hammer initializations). Each image comes with a tag that corresponds to the version of Chipyard cloned/set-up in that image. Not including a tag during the pull will pull the image with the latest version of Chipyard.
First, pull the Docker image. Run:

.. code-block:: shell
sudo docker pull ucbbar/chipyard-image:<TAG>
To run the Docker container in an interactive shell, run:

.. code-block:: shell
sudo docker run -it ucbbar/chipyard-image bash
What's Next?
-------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions scripts/centos-req.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ sudo yum install -y centos-release-scl
sudo yum install -y devtoolset-8-make
# install DTC
sudo yum install -y dtc
sudo yum install -y python

# install verilator
git clone http://git.veripool.org/git/verilator
Expand Down
8 changes: 8 additions & 0 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# used with the dockerfile to set up enviroment variables by running env.sh
# adapted from https://stackoverflow.com/questions/55921914/how-to-source-a-script-with-environment-variables-in-a-docker-build-process

. /home/riscvuser/chipyard/env.sh

exec "$@"
Loading

0 comments on commit a86f801

Please sign in to comment.