-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
103 lines (81 loc) · 3.12 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
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
95
96
97
98
99
100
101
102
103
# =================================
# Build and test environment for CI
# =================================
FROM ubuntu:23.04 as cpp-docker-common
ARG DEBIAN_FRONTEND=noninteractive
ARG CLANG_COMPILER_VERSION=15
ARG CMAKE_VERSION=3.27.7
ENV PATH="${PATH}:/cmake-${CMAKE_VERSION}-linux-x86_64/bin/:"
RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install --fix-missing \
binutils \
build-essential \
bzip2 \
cppcheck \
ccache \
doxygen \
graphviz \
git \
lsb-release \
ninja-build \
pipx \
python3 \
python3-pip \
python3-setuptools \
python3-venv \
shellcheck \
ssh \
software-properties-common \
sudo \
tar \
valgrind \
wget
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh \
&& chmod +x cmake-${CMAKE_VERSION}-linux-x86_64.sh \
&& ./cmake-${CMAKE_VERSION}-linux-x86_64.sh --include-subdir --skip-license \
&& rm cmake-${CMAKE_VERSION}-linux-x86_64.sh
RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
RUN apt-get -y install --fix-missing clang-format clang-tidy clang-${CLANG_COMPILER_VERSION} llvm-${CLANG_COMPILER_VERSION} llvm-${CLANG_COMPILER_VERSION}-dev libclang-${CLANG_COMPILER_VERSION}-dev \
&& apt-get autoremove -y && apt-get clean
RUN mkdir iwyu && cd iwyu \
&& git clone --branch clang_${CLANG_COMPILER_VERSION} https://github.com/include-what-you-use/include-what-you-use.git \
&& mkdir build && cd build \
&& cmake -G "Ninja" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${CLANG_COMPILER_VERSION} ../include-what-you-use \
&& sudo ninja install \
&& cd ../.. \
&& rm -rf iwyu
# =================================
# DEV environment for local machine
# =================================
FROM cpp-docker-common as cpp-docker-dev
ARG DEV_USER=dev
ENV PATH="${PATH}:/home/${DEV_USER}/.local/bin/"
RUN apt-get -y install --fix-missing vim \
&& apt-get autoremove -y && apt-get clean
# Dev user for inside the container
RUN groupadd -f -g 1000 ${DEV_USER} && \
useradd --non-unique -m -u 1000 -g 1000 -d /home/${DEV_USER} -s /bin/bash ${DEV_USER} && \
usermod -a -G adm,cdrom,sudo,dip,plugdev ${DEV_USER} && \
echo "${DEV_USER}:${DEV_USER}" | chpasswd && \
echo "${DEV_USER} ALL=(ALL:ALL) ALL" >> /etc/sudoers
# fix "Missing privilege separation directory" error in SSHD
# see: https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/45234
RUN chmod 0755 /var/run/sshd
COPY ccache.conf /etc/.
USER ${DEV_USER}
WORKDIR /home/${DEV_USER}
RUN sed -i 's/\\h/docker/;s/01;32m/01;33m/' /home/${DEV_USER}/.bashrc \
&& mkdir /home/${DEV_USER}/git
RUN pipx install conan
FROM cpp-docker-common as cpp-docker-ci
ARG CI_USER=ci
ENV PATH="${PATH}:/home/${CI_USER}/.local/bin/"
# Dev user for inside the container
RUN groupadd -f -g 1000 ${CI_USER} && \
useradd --non-unique -m -u 1000 -g 1000 -d /home/${CI_USER} -s /bin/bash ${CI_USER} && \
usermod -a -G adm,cdrom,sudo,dip,plugdev ${CI_USER} && \
echo "${CI_USER}:${CI_USER}" | chpasswd && \
echo "${CI_USER} ALL=(ALL:ALL) ALL" >> /etc/sudoers
COPY ccache.conf /etc/.
USER ${CI_USER}
RUN pipx install conan
WORKDIR /home/${CI_USER}