-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (37 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
46 lines (37 loc) · 1.19 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
# debian slim to reduce image size
FROM debian:12-slim
# build arguments and environment variables
ARG USERNAME=cppuser
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ENV WORK_DIR="/workspace"
ENV CURR_USR=$USERNAME
# from this line onward, all commands will be executed in the following directory
WORKDIR $WORK_DIR
# copy needed files into the container
COPY ./CMakeLists.txt ./CMakeLists.txt
COPY ./.vscode ./.vscode
# essential tools for cpp development
RUN apt-get update && apt-get install -y \
sudo \
build-essential \
cmake \
gdb \
git \
curl \
libboost-all-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# create a non-root user with sudo privileges
RUN groupadd --gid $USER_GID $USERNAME && \
useradd --uid $USER_UID --gid $USER_GID -ms /bin/bash $USERNAME && \
echo "$USERNAME ALL=\(root\) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME && \
chown -R $USERNAME:$USERNAME $WORK_DIR
# set the user to run the container
USER $USERNAME
# create and add the user's bin directory to the PATH env variable
RUN mkdir -p /home/$USERNAME/bin
ENV PATH="/home/$USERNAME/bin:${PATH}"
# default command (shell)
CMD ["/bin/bash"]