-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpp.Dockerfile
157 lines (131 loc) · 3.89 KB
/
cpp.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
##############################################
# C++ development docker file
##############################################
###########################################
# Base image
###########################################
FROM ubuntu:22.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
# Install language
RUN apt-get update && apt-get install -y --no-install-recommends \
locales \
&& locale-gen en_US.UTF-8 \
&& update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/*
ENV LANG en_US.UTF-8
# Install timezone
RUN ln -fs /usr/share/zoneinfo/EST /etc/localtime \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends tzdata \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& rm -rf /var/lib/apt/lists/*
# Set timezone
ENV TZ="Canada/Eastern"
RUN date
# Install C++ compilers
RUN apt-get update && apt-get install -y --no-install-recommends \
dialog \
ssh \
apt-utils \
sudo \
build-essential \
gcc \
g++ \
clang \
cmake \
make \
git \
&& rm -rf /var/lib/apt/lists/*
ARG USERNAME=cpp
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create a non-root user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
# [Optional] Add sudo support for the non-root user
&& apt-get update \
&& apt-get install -y --no-install-recommends sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME \
# Cleanup
&& rm -rf /var/lib/apt/lists/* \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc
# Set user to non-root user
USER $USERNAME
# Create a development directory
RUN mkdir -p ~/Dev
# Install latest stable eigen release
RUN git config --global http.sslverify false \
&& git clone https://gitlab.com/libeigen/eigen.git ~/Dev/external/eigen \
&& cd ~/Dev/external/eigen \
&& mkdir build && cd build \
&& cmake .. \
&& sudo make install \
&& git config --global http.sslverify false
ENV DEBIAN_FRONTEND=
###########################################
# Develop image
###########################################
FROM base AS dev
ARG USERNAME
ARG USER_UID
ARG USER_GID
ENV DEBIAN_FRONTEND=noninteractive
RUN sudo apt-get update \
&& sudo apt-get install -y --no-install-recommends \
clangd \
zsh \
bash-completion \
build-essential \
cmake \
gdb \
vim \
wget \
python3-pip \
&& sudo rm -rf /var/lib/apt/lists/*
# Install fzf
RUN git clone https://github.com/junegunn/fzf.git ~/Dev/external/fzf \
&& cd ~/Dev/external/fzf \
&& ./install --all
# Clone custom workstation setup and setup packages
RUN git clone https://github.com/aalbaali/workstation_setup.git ~/Dev/workstation_setup \
&& cd ~/Dev/workstation_setup \
&& sudo ./scripts/install_packages.sh \
&& rm ~/.bashrc \
&& rm ~/.zshrc \
&& if [ -f ~/.gitconfig ]; then rm ~/.gitconfig; fi \
&& ./scripts/post_install_setup.sh \
--zsh \
--zsh-setup \
--bash \
--functions \
--git \
--nvim \
--nvim-setup \
--clang_format \
--gdb \
--tmux \
--tmux-setup
# Run zsh to initialize
USER $USERNAME
ENV DEBIAN_FRONTEND=
CMD ["zsh"]
###########################################
# opencv layer
###########################################
from dev AS opencv
ARG USERNAME
ARG USER_UID
ARG USER_GID
ENV DEBIAN_FRONTEND=noninteractive
RUN sudo apt-get update \
&& sudo apt-get install -y \
libopencv-dev \
python3-opencv \
libcanberra-gtk-module \
libcanberra-gtk3-module \
&& sudo rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=
CMD ["zsh"]