Skip to content

Commit b65f250

Browse files
authored
Devcontainer support (verilator#4748)
devcontainers are a convenient way to provide users a reproducible build environment. It is currently supported by Visual Studio Code, Visual Studio and IntelliJ. When the user opens the verilator repo in VSCode with the standard devcontainer extension installed, VSCode will ask the user if they want to reopen in the devcontainer, then build the Docker image as per our definition and then restart VSCode 'remotely' attached to the Docker container. More information: https://code.visualstudio.com/docs/devcontainers/containers Also: - zlibc is missing on Debian-based systems now - Add non-root user to Dockerfile and make default
1 parent b60117c commit b65f250

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Diff for: .devcontainer/devcontainer.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Verilator Build Environment",
3+
4+
"build": {
5+
"dockerfile": "../ci/docker/buildenv/Dockerfile"
6+
}
7+
8+
}

Diff for: ci/docker/buildenv/Dockerfile

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88

99
FROM ubuntu:22.04
1010

11+
# Create the user
12+
RUN groupadd verilator \
13+
&& useradd -g verilator -m verilator -s /bin/bash \
14+
&& apt-get update \
15+
&& apt-get install --no-install-recommends -y sudo \
16+
&& apt-get clean \
17+
&& rm -rf /var/lib/apt/lists/* \
18+
&& echo verilator ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/verilator \
19+
&& chmod 0440 /etc/sudoers.d/verilator
20+
1121
RUN apt-get update \
1222
&& DEBIAN_FRONTEND=noninteractive \
1323
apt-get install --no-install-recommends -y \
@@ -33,7 +43,6 @@ RUN apt-get update \
3343
perl \
3444
python3 \
3545
wget \
36-
zlibc \
3746
zlib1g \
3847
zlib1g-dev \
3948
&& apt-get clean \
@@ -52,6 +61,8 @@ COPY build.sh /tmp/build.sh
5261

5362
ENV VERILATOR_AUTHOR_SITE=1
5463

64+
USER verilator
65+
5566
WORKDIR /work
5667

5768
ENTRYPOINT [ "/tmp/build.sh" ]

0 commit comments

Comments
 (0)