forked from sjain-stanford/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
94 lines (82 loc) · 3.14 KB
/
Copy pathDockerfile
File metadata and controls
94 lines (82 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
ARG BASE_IMG=ubuntu:24.04
FROM ${BASE_IMG} AS dev-base
# https://askubuntu.com/questions/1513927/ubuntu-24-04-docker-images-now-includes-user-ubuntu-with-uid-gid-1000
RUN userdel -r ubuntu || true
# Specify user IDs and recreate env in container
# These are passed in from the build_docker.sh script
# Defaults to root user when not specified
ARG GROUP=root
ARG GID=0
ARG USER=root
ARG UID=0
ARG WORKDIR=/workspace
# Run below commands as root
USER root
# Install basic packages
RUN apt-get update && \
apt-get install -y \
aria2 \
bash-completion \
black \
sudo \
catch2 \
ccache \
clang \
clang-format \
clang-tidy \
cmake-curses-gui \
cmake \
curl \
gdb \
git \
lcov \
lld \
ninja-build \
pre-commit \
python3-dev \
python3-venv \
vim \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Setup GitHub CLI repository and install gh
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian
RUN mkdir -p -m 755 /etc/apt/keyrings && \
wget -nv -O /tmp/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg && \
cat /tmp/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null && \
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \
apt-get update && \
apt-get install -y gh && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/githubcli-archive-keyring.gpg
# Install bazel
ARG ARCH=x86_64
ARG BAZEL_VERSION=6.4.0
RUN wget -q https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-${ARCH} -O /usr/bin/bazel && \
chmod a+x /usr/bin/bazel
# Install beads_rust (br) - agent-first issue tracker
RUN curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/beads_rust/main/install.sh" | bash -s -- --system
# Set workdir before launching container
WORKDIR ${WORKDIR}
# Install IREE, ROCm, HIP deps through an entrypoint script
# to keep the base image small and portable.
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY activate /usr/local/bin/activate
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/bin/bash"]
# Mirror user and group within container and set ownerships
# only if building as non-root user (i.e., GROUP, GID, USER,
# UID and WORKDIR are specified args to docker build)
RUN if [ "$UID" != "0" ]; then \
groupadd -o -g ${GID} ${GROUP} && \
useradd -u ${UID} -g ${GROUP} -ms /bin/bash ${USER} && \
usermod -aG sudo ${USER} && \
echo "${USER} ALL=(ALL) NOPASSWD: /usr/bin/apt-get, /usr/bin/apt, /usr/bin/dpkg, /usr/bin/tee, /usr/bin/chown, /usr/bin/chmod" > /etc/sudoers.d/${USER} && \
chown -R ${USER}:${GROUP} ${WORKDIR}; \
fi
# Strip setuid/setgid bits — none are needed inside a dev container
RUN find / -xdev -perm /6000 -type f -exec chmod a-s {} + 2>/dev/null || true
# Switch to user
USER ${USER}