-
Notifications
You must be signed in to change notification settings - Fork 37
/
Dockerfile
61 lines (56 loc) · 2.88 KB
/
Dockerfile
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
ARG UBUNTU_VERSION
FROM ubuntu:${UBUNTU_VERSION} as base
ARG GCC_VERSION
ARG CLANG_VERSION
RUN set -ex; \
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections; \
apt-get update; \
apt-get install -y -q apt-utils dialog; \
apt-get install -y -q sudo aptitude flex bison cpio libncurses5-dev make git exuberant-ctags sparse bc libssl-dev libelf-dev bsdmainutils dwarves xz-utils zstd; \
if [ "$GCC_VERSION" ]; then \
apt-get install -y -q gcc-${GCC_VERSION} g++-${GCC_VERSION} gcc-${GCC_VERSION}-plugin-dev \
gcc-${GCC_VERSION}-aarch64-linux-gnu g++-${GCC_VERSION}-aarch64-linux-gnu \
gcc-${GCC_VERSION}-arm-linux-gnueabi g++-${GCC_VERSION}-arm-linux-gnueabi; \
if [ "$GCC_VERSION" != "4.9" ]; then \
apt-get install -y -q gcc-${GCC_VERSION}-plugin-dev-aarch64-linux-gnu gcc-${GCC_VERSION}-plugin-dev-arm-linux-gnueabi; \
fi; \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 100; \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} 100; \
update-alternatives --install /usr/bin/aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc-${GCC_VERSION} 100; \
update-alternatives --install /usr/bin/aarch64-linux-gnu-g++ aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-g++-${GCC_VERSION} 100; \
update-alternatives --install /usr/bin/arm-linux-gnueabi-gcc arm-linux-gnueabi-gcc /usr/bin/arm-linux-gnueabi-gcc-${GCC_VERSION} 100; \
update-alternatives --install /usr/bin/arm-linux-gnueabi-g++ arm-linux-gnueabi-g++ /usr/bin/arm-linux-gnueabi-g++-${GCC_VERSION} 100; \
fi; \
if [ "$CLANG_VERSION" ]; then \
apt-get install -y -q clang-${CLANG_VERSION} lld-${CLANG_VERSION} clang-tools-${CLANG_VERSION}; \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANG_VERSION} 100; \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VERSION} 100; \
update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${CLANG_VERSION} 100; \
fi
ARG UNAME
ARG UID
ARG GNAME
ARG GID
RUN set -x; \
# These commands are allowed to fail (it happens for root, for example).
# The result will be checked in the next RUN.
userdel -r `getent passwd ${UID} | cut -d : -f 1` > /dev/null 2>&1; \
groupdel -f `getent group ${GID} | cut -d : -f 1` > /dev/null 2>&1; \
groupadd -g ${GID} ${GNAME}; \
useradd -u $UID -g $GID -G sudo -ms /bin/bash ${UNAME}; \
mkdir /src; \
chown -R ${UNAME}:${GNAME} /src; \
mkdir /out; \
chown -R ${UNAME}:${GNAME} /out; \
echo "${UNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
USER ${UNAME}:${GNAME}
WORKDIR /src
RUN set -ex; \
id | grep "uid=${UID}(${UNAME}) gid=${GID}(${GNAME})"; \
sudo ls; \
pwd | grep "^/src"; \
touch /src/test; \
rm /src/test; \
touch /out/test; \
rm /out/test
CMD ["bash"]