-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
101 lines (87 loc) · 3.08 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
FROM ubuntu:18.04
#FROM ubuntu:bionic
ARG DEBIAN_FRONTEND="noninteractive"
ARG TIME_ZONE="Atlantic/Canary"
ARG USERNAME=user
ARG UID=1000
ARG GID=1000
#ARG CODE_SERVER_VER=3.12.0
ARG CODE_SERVER_VER=4.2.0
LABEL authors="Marcos Colebrook"
LABEL description="Container image for VS Code and CDR code-server with Development Tools"
WORKDIR /root
ENV TZ=$TIME_ZONE \
TEMP=/tmp
# DBUS_SESSION_BUS_ADDRESS="autolaunch:" \
# LANG="en_US.UTF-8" \
# LANGUAGE="en_US.UTF-8"
# VS Code
RUN apt update \
&& apt install -y wget software-properties-common apt-transport-https \
&& wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | apt-key add - \
&& add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" \
&& apt update \
&& apt install -y --no-install-recommends \
build-essential \
code \
dbus \
dbus-x11 \
gdb \
gnome-keyring \
iproute2 \
libasound2 \
libatk-bridge2.0-0 \
libcurl4 \
libfuse2 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libgl1 \
libgl1-mesa-glx \
libgtk-3.0 \
libnotify-bin \
libsecret-1-dev \
libssl-dev \
libx11-dev \
libx11-xcb-dev \
libx11-xcb1 \
libxkbfile-dev \
libxshmfence1 \
lsb-release \
openssh-client \
python-dbus \
python-gtk2 \
python-pip \
sudo \
tzdata \
unzip \
&& apt autoremove -y \
&& apt clean -y \
&& rm -rf /var/lib/apt/lists/*
# code-server
RUN wget -q "https://github.com/cdr/code-server/releases/download/v${CODE_SERVER_VER}/code-server_${CODE_SERVER_VER}_amd64.deb" \
&& apt install "./code-server_${CODE_SERVER_VER}_amd64.deb" \
&& rm "code-server_${CODE_SERVER_VER}_amd64.deb"
COPY init-dbus.sh /usr/local/share/
RUN mkdir -p /var/run/dbus \
&& chmod +x /usr/local/share/init-dbus.sh
RUN groupadd --gid $GID $USERNAME && \
useradd --uid $UID --gid $GID --groups root,staff --create-home --shell /bin/bash --comment 'code user' $USERNAME && \
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd && \
echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep
USER $USERNAME
ENV HOME=/home/$USERNAME
WORKDIR $HOME
ENV PATH=$PATH:$HOME/scripts
COPY --chown=user:user scripts/*.sh scripts/
RUN code --extensions-dir .config/Code/extensions --install-extension ms-vscode.cpptools \
&& mkdir -p .config/code-server .local/share/code-server/User \
&& chmod a+x scripts/*.sh \
&& sh -c 'echo "eval \`dbus-launch --auto-syntax\`" >> /home/${USERNAME}/.bashrc'
#&& sh -c 'echo "export $(dbus-launch)" >> /home/${USERNAME}/.bashrc'
#&& sh -c 'echo "export "$(dbus-launch)"; export NSS_USE_SHARED_DB=ENABLED" >> /home/${USERNAME}/.bashrc'
# remove unnecessary tools to prevent cyberattacks
# https://www.docker.com/wp-content/uploads/2022/04/cheat-sheet-docker-snyk-log4shell.pdf
RUN sudo apt remove wget -y
WORKDIR $HOME/src
ENTRYPOINT [ "/usr/local/share/init-dbus.sh" ]
CMD [ "/bin/bash" ]