|
1 | 1 | 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 |
2 | 10 |
|
3 | 11 | RUN apt update
|
4 | 12 |
|
| 13 | + |
| 14 | +### Install required packages |
| 15 | + |
5 | 16 | RUN DEBIAN_FRONTEND=noninteractive \
|
6 | 17 | apt install -y --no-install-recommends \
|
7 | 18 | apt-utils \
|
8 | 19 | ca-certificates \
|
| 20 | + curl \ |
| 21 | + dialog \ |
9 | 22 | bash-completion \
|
10 | 23 | build-essential \
|
11 | 24 | less \
|
12 | 25 | git \
|
| 26 | + iproute2 \ |
| 27 | + media-types \ |
13 | 28 | ssh \
|
14 | 29 | sudo \
|
15 | 30 | unzip \
|
| 31 | + webfs \ |
16 | 32 | wget
|
17 | 33 |
|
| 34 | + |
| 35 | +### Install Alire |
| 36 | + |
18 | 37 | 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 && \ |
21 | 40 | mv bin/alr /usr/local/bin/alr
|
22 | 41 |
|
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 &&\ |
25 | 48 | echo "root:root" | chpasswd &&\
|
26 | 49 | echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
27 | 50 |
|
28 |
| -USER user |
29 |
| -WORKDIR /home/user |
| 51 | + |
| 52 | +### Install & Setup Alice |
| 53 | + |
| 54 | +USER ${user_name} |
| 55 | +WORKDIR /home/${user_name} |
30 | 56 | RUN alr --no-color index --reset-community
|
31 | 57 | RUN alr --no-color index --add=git+https://github.com/alice-adventures/alice-index --name=alice
|
32 | 58 | RUN alr --no-color index --update-all
|
33 | 59 | RUN alr --no-color --non-interactive get alice
|
34 | 60 | RUN mv alice_*/ alice
|
35 | 61 |
|
36 |
| -WORKDIR /home/user/alice |
| 62 | +WORKDIR /home/${user_name}/alice |
37 | 63 | RUN git clone https://github.com/alice-adventures/project_euler.git
|
38 | 64 |
|
39 |
| -WORKDIR /home/user/alice/project_euler |
| 65 | +WORKDIR /home/${user_name}/alice/project_euler |
40 | 66 | RUN ./action/usr-setup.sh
|
41 | 67 |
|
42 |
| -WORKDIR /home/user/alice/project_euler/usr/rocher |
43 |
| -RUN alr --no-color --non-interactive build |
44 | 68 |
|
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