Skip to content

Commit 746e5ea

Browse files
committed
Dockerfile: new arguments and code-server
1 parent c7b7c32 commit 746e5ea

File tree

1 file changed

+86
-13
lines changed

1 file changed

+86
-13
lines changed

Dockerfile

+86-13
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,120 @@
11
FROM ubuntu:22.04
2+
ARG alire_version=1.2.2
3+
ARG user_name=guest
4+
ARG user_uid=1000
5+
ARG user_gid=1000
6+
ARG group_name=${user_name}
7+
ARG code_server_version=4.13.0
8+
ARG code_server_auth=none
9+
ARG code_server_port=47801
210

311
RUN apt update
412

13+
14+
### Install required packages
15+
516
RUN DEBIAN_FRONTEND=noninteractive \
617
apt install -y --no-install-recommends \
718
apt-utils \
819
ca-certificates \
20+
curl \
21+
dialog \
922
bash-completion \
1023
build-essential \
1124
less \
1225
git \
26+
iproute2 \
27+
media-types \
1328
ssh \
1429
sudo \
1530
unzip \
31+
webfs \
1632
wget
1733

34+
35+
### Install Alire
36+
1837
WORKDIR /tmp
19-
RUN wget -nv https://github.com/alire-project/alire/releases/download/v1.2.2/alr-1.2.2-bin-x86_64-linux.zip && \
20-
unzip alr-1.2.2-bin-x86_64-linux.zip && \
38+
RUN wget -nv https://github.com/alire-project/alire/releases/download/v${alire_version}/alr-${alire_version}-bin-x86_64-linux.zip && \
39+
unzip alr-${alire_version}-bin-x86_64-linux.zip && \
2140
mv bin/alr /usr/local/bin/alr
2241

23-
RUN useradd -rm -d /home/user -s /bin/bash -G sudo user &&\
24-
echo "user:user" | chpasswd &&\
42+
43+
### Add user ${user_name}
44+
45+
RUN groupadd --force --gid ${user_gid} ${group_name} &&\
46+
useradd --create-home --home-dir /home/${user_name} --gid ${user_gid} --groups sudo --shell /bin/bash --uid ${user_uid} ${user_name} &&\
47+
echo "${user_name}:${user_name}" | chpasswd &&\
2548
echo "root:root" | chpasswd &&\
2649
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
2750

28-
USER user
29-
WORKDIR /home/user
51+
52+
### Install & Setup Alice
53+
54+
USER ${user_name}
55+
WORKDIR /home/${user_name}
3056
RUN alr --no-color index --reset-community
3157
RUN alr --no-color index --add=git+https://github.com/alice-adventures/alice-index --name=alice
3258
RUN alr --no-color index --update-all
3359
RUN alr --no-color --non-interactive get alice
3460
RUN mv alice_*/ alice
3561

36-
WORKDIR /home/user/alice
62+
WORKDIR /home/${user_name}/alice
3763
RUN git clone https://github.com/alice-adventures/project_euler.git
3864

39-
WORKDIR /home/user/alice/project_euler
65+
WORKDIR /home/${user_name}/alice/project_euler
4066
RUN ./action/usr-setup.sh
4167

42-
WORKDIR /home/user/alice/project_euler/usr/rocher
43-
RUN alr --no-color --non-interactive build
4468

45-
USER user
46-
WORKDIR /home/user
47-
ENTRYPOINT ["/bin/bash"]
69+
### Install code-server & additional packages
70+
71+
USER root
72+
WORKDIR /tmp
73+
RUN curl -fOL https://github.com/coder/code-server/releases/download/v${code_server_version}/code-server_${code_server_version}_amd64.deb && \
74+
dpkg -i code-server_${code_server_version}_amd64.deb
75+
76+
WORKDIR /usr/local/bin
77+
RUN echo \
78+
"#!/bin/bash\n\
79+
IP_ADDR=\$(ip address show dev eth0 | tr -s [:space:] | grep inet | cut -d' ' -f3 | cut -d/ -f1)\n\
80+
code-server --auth ${code_server_auth}\
81+
--disable-telemetry\
82+
--bind-addr \$IP_ADDR:47801\
83+
--ignore-last-opened \
84+
--disable-workspace-trust \
85+
--welcome-text 'Welcome to Alice in Dockerland'\
86+
\$* >/tmp/code-server.log 2>&1 &\n\
87+
echo Please visit http://\$IP_ADDR:\${code_server_port} to access vscode"\
88+
> start-code-server.sh
89+
90+
RUN echo \
91+
"#!/bin/bash\n\
92+
ps x | grep -e '/usr/.*/code-server' | grep -v grep | sed -e 's/ */ /g' | cut -d' ' -f2 | xargs -I{} kill -9 {} >/dev/null 2>&1"\
93+
> stop-code-server.sh
94+
95+
RUN chmod a+x start-code-server.sh stop-code-server.sh
96+
97+
USER ${user_name}
98+
WORKDIR /home/${user_name}
99+
RUN code-server --install-extension Adacore.ada && \
100+
code-server --install-extension yzhang.markdown-all-in-one && \
101+
code-server --install-extension bungcip.better-toml && \
102+
code-server --install-extension mhutchie.git-graph
103+
104+
105+
### Entrypoint
106+
107+
USER root
108+
WORKDIR /usr/local/bin
109+
RUN echo \
110+
"#!/bin/bash\n\
111+
webfsd\n\
112+
start-code-server.sh\n\
113+
/bin/bash"\
114+
> entrypoint.sh
115+
116+
RUN chmod a+x entrypoint.sh
117+
118+
USER ${user_name}
119+
WORKDIR /home/${user_name}
120+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

0 commit comments

Comments
 (0)