Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use root user for the Dockerfile #883

Merged
merged 5 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ version: 2.1
parameters:
tools-cache-version:
type: string
default: "v8"
default: "v9"

# default execution env.s
executors:
main-env:
docker:
- image: ucbbar/chipyard-ci-image:c29770
- image: ucbbar/chipyard-ci-image:1d51bb90
environment:
JVM_OPTS: -Xmx3200m # Customize the JVM maximum heap limit

Expand Down Expand Up @@ -41,7 +41,7 @@ commands:
- save_cache:
key: << parameters.tools-version >>-installed-<< pipeline.parameters.tools-cache-version >>-{{ checksum "../<< parameters.tools-version >>.hash" }}
paths:
- "/home/riscvuser/<< parameters.tools-version >>-install"
- "/root/<< parameters.tools-version >>-install"

ssh-checkout:
description: "Add SSH key and checkout code"
Expand Down Expand Up @@ -95,7 +95,7 @@ commands:
- save_cache:
key: << parameters.group-key >>-{{ .Branch }}-{{ .Revision }}
paths:
- "/home/riscvuser/project"
- "/root/project"

run-tests:
description: "Run a set of tests"
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
- save_cache:
key: extra-tests-{{ .Branch }}-{{ .Revision }}
paths:
- "/home/riscvuser/project/tests"
- "/root/project/tests"

prepare-chipyard-cores:
executor: main-env
Expand Down
18 changes: 5 additions & 13 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,7 @@ RUN apt-get update && \
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"
WORKDIR /root

# Install Chipyard and run ubuntu-req.sh to install necessary dependencies
RUN git clone https://github.com/ucb-bar/chipyard.git && \
Expand All @@ -38,6 +26,10 @@ RUN git clone https://github.com/ucb-bar/chipyard.git && \
./scripts/ubuntu-req.sh 1>/dev/null && \
sudo rm -rf /var/lib/apt/lists/*

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

# BUILD IMAGE WITH TOOLCHAINS

Expand Down
2 changes: 1 addition & 1 deletion scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# 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
. /root/chipyard/env.sh

exec "$@"