Use just code-server. May use full code for web UI in the future (see supervisord.conf)

This commit is contained in:
2024-11-15 02:04:17 +01:00
parent c2ba9c4aa3
commit a67dc17751
3 changed files with 115 additions and 15 deletions

View File

@@ -1,29 +1,45 @@
FROM ubuntu
LABEL maintainer="Roman Vanicek <roman.vanicek@ivasoft.cz>"
RUN set -x -e; \
apt update; \
apt install -y openssh-server wget gpg nano git git-lfs dotnet8 chromium; \
apt install -y supervisor openssh-server wget gpg nano git git-lfs chromium; \
git lfs install; \
mkdir /run/sshd /config /config/workspace; \
# Install dotnet manually as packaged dotnet does not have all the workloads
mkdir -p /home/abc/dotnet; \
wget https://download.visualstudio.microsoft.com/download/pr/db901b0a-3144-4d07-b8ab-6e7a43e7a791/4d9d1b39b879ad969c6c0ceb6d052381/dotnet-sdk-8.0.401-linux-x64.tar.gz -O /tmp/dotnet.tar.gz; \
tar zxf /tmp/dotnet.tar.gz -C /home/abc/dotnet; \
echo DOTNET_ROOT=/home/abc/dotnet >> /etc/environment; \
mkdir -p /home/code/dotnet; \
wget -q https://download.visualstudio.microsoft.com/download/pr/4e3b04aa-c015-4e06-a42e-05f9f3c54ed2/74d1bb68e330eea13ecfc47f7cf9aeb7/dotnet-sdk-8.0.404-linux-x64.tar.gz -O /tmp/dotnet.tar.gz; \
tar zxf /tmp/dotnet.tar.gz -C /home/code/dotnet; \
echo DOTNET_ROOT=/home/code/dotnet >> /etc/environment; \
#export PATH=$PATH:$HOME/dotnet
# Code
wget https://vscode.download.prss.microsoft.com/dbazure/download/stable/4849ca9bdf9666755eb463db297b69e5385090e3/code_1.93.0-1725459079_amd64.deb -O /tmp/code.deb;
apt install -y /tmp/code.deb; \
# Code Server
codeServerVer=$(wget -q https://update.code.visualstudio.com/api/latest/server-linux-x64-web/stable -O -|grep -oh 'version":"[^"]*'|cut -c 11-); \
wget -q https://update.code.visualstudio.com/commit:${codeServerVer}/server-linux-x64/stable -O /tmp/code.tar.gz; \
mkdir -p /home/code/.vscode-server/cli/servers/Stable-${codeServerVer}/server; \
tar xzf /tmp/code.tar.gz --directory /home/code/.vscode-server/cli/servers/Stable-${codeServerVer}/server --strip-components=1; \
# Code
#wget https://vscode.download.prss.microsoft.com/dbazure/download/stable/4849ca9bdf9666755eb463db297b69e5385090e3/code_1.93.0-1725459079_amd64.deb -O /tmp/code.deb;
#apt install -y /tmp/code.deb; \
# Android SDK
mkdir -p /home/abc/sdk; \
mkdir -p /home/code/sdk; \
apt install -y zip openjdk-17-jdk-headless; \
wget -q https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip -O /home/abc/sdk/commandlinetools.zip && unzip -q /home/abc/sdk/commandlinetools.zip -d /home/abc/sdk; \
echo ANDROID_SDK_ROOT=/home/abc/sdk >> /etc/environment; \
export PATH=/home/abc/sdk/cmdline-tools/bin:$PATH ANDROID_SDK_ROOT=/home/abc/sdk; \
wget -q https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip -O /home/code/sdk/commandlinetools.zip && unzip -q /home/code/sdk/commandlinetools.zip -d /home/code/sdk; \
echo ANDROID_SDK_ROOT=/home/code/sdk >> /etc/environment; \
export PATH=/home/code/sdk/cmdline-tools/bin:$PATH ANDROID_SDK_ROOT=/home/code/sdk; \
yes|sdkmanager --sdk_root=/drone/src/sdk "platform-tools" "build-tools;34.0.0" "platforms;android-34"; \
yes|sdkmanager --sdk_root=/drone/src/sdk --licenses; \
# Clean up
rm /tmp/code.deb /tmp/dotnet.tar.gz /home/abc/sdk/commandlinetools.zip; \
rm -rf /var/lib/apt/lists/*
rm /tmp/code.tar.gz /tmp/dotnet.tar.gz /home/code/sdk/commandlinetools.zip; \
rm -rf /var/lib/apt/lists/* ;\
# Mark the docker as not run yet, to allow entrypoint to do its stuff
touch /firstrun
# docker create --name code --network host --entrypoint tail ubuntu -f /dev/null
COPY entrypoint.sh /entrypoint.sh
COPY supervisord.conf /etc/supervisord.conf
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]

51
entrypoint.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
set -e
CODE_UUID="${BACKUPPC_UUID:-1001}"
CODE_GUID="${BACKUPPC_GUID:-1001}"
CODE_USERNAME=$(getent passwd "$CODE_UUID" | cut -d: -f1)
CODE_GROUPNAME=$(getent group "$CODE_GUID" | cut -d: -f1)
if [ -f /firstrun ]; then
echo 'First run of the container. Code will be configured.'
echo 'If exist, configuration and data will be reused and upgraded as needed.'
# Configure timezone if needed
if [ -n "$TZ" ]; then
cp /usr/share/zoneinfo/$TZ /etc/localtime
fi
# Create code user/group if needed
if [ -z "$CODE_GROUPNAME" ]; then
groupadd -r -g "$CODE_GUID" code
CODE_GROUPNAME="code"
fi
if [ -z "$CODE_USERNAME" ]; then
if [ "$CODE_PASSWORD" ] && [ "$CODE_PASSWORD_FILE" ]; then
echo 'error: both CODE_PASSWORD and CODE_PASSWORD_FILE are set (but are exclusive)\n'
exit 1
fi
password=""
if [ "$CODE_PASSWORD" ]; then
password="$CODE_PASSWORD"
elif [ "$CODE_PASSWORD_FILE" ]; then
password="$(< ${CODE_PASSWORD_FILE})"
fi
useradd -r -d /home/code -s /bin/bash -g "$CODE_GUID" -u "$CODE_UUID" -M -N code
echo "code:$password" | chpasswd
CODE_USERNAME="code"
else
usermod -d /home/code "$CODE_USERNAME"
fi
chown "$CODE_USERNAME":"$CODE_GROUPNAME" /home/code
# Clean
rm -rf /firstrun
fi
export CODE_USERNAME
cd /home/code
exec "$@"

33
supervisord.conf Normal file
View File

@@ -0,0 +1,33 @@
[unix_http_server]
file = /tmp/supervisor.sock
username = dummy
password = dummy
[supervisord]
user = root
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups = 10
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = true
minfds = 1024
minprocs = 200
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl = unix:///tmp/supervisor.sock
username = dummy
password = dummy
[program:ssh]
command = /usr/sbin/sshd -D
#[program:code]
#command = /usr/bin/code serve-web --host 0.0.0.0 --port 80
#redirect_stderr = true
#stdout_logfile = /dev/stdout
#stdout_logfile_maxbytes = 0
#user = %(ENV_CODE_USERNAME)s