-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpp.Dockerfile
135 lines (112 loc) · 3.27 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
##############################################
# C++ development docker file
##############################################
###########################################
# Base image
###########################################
FROM ubuntu:22.04 AS base
ARG DEBIAN_FRONTEND=noninteractive
# Set timezone
ENV TZ="America/New_York"
# Install timezone
RUN 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/* \
&& ln -fs /usr/share/zoneinfo/EST /etc/localtime
# 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 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="dev"
ENV USERNAME=$USERNAME
ENV USER=$USERNAME
ARG USER_UID=1001
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
# Set user to non-root user
USER $USERNAME
# Create a development directory
RUN mkdir -p ~/Dev
# Install latest stable eigen release
ARG EIGEN_VERSION=3.4.0
RUN git config --global http.sslverify false \
&& git clone https://gitlab.com/libeigen/eigen.git -b $EIGEN_VERSION ~/Dev/external/eigen \
&& cd ~/Dev/external/eigen \
&& mkdir build && cd build \
&& cmake .. \
&& sudo make install \
&& git config --global http.sslverify false
###########################################
# Develop image
###########################################
FROM base AS dev
ARG USERNAME
ARG USER_UID
ARG USER_GID
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 \
curl \
ca-certificates \
&& 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
# Install my workstation setup
RUN curl -sS https://raw.githubusercontent.com/aalbaali/workstation_setup/master/clone_and_run_dev_playbook | bash -
# Run zsh to initialize
USER $USERNAME
CMD ["zsh"]
###########################################
# opencv layer
###########################################
FROM dev AS opencv
ARG USERNAME
ARG USER_UID
ARG USER_GID
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/*
CMD zsh