v1-beta #2

Merged
musabe24 merged 4 commits from v1-beta into main 2024-02-25 19:40:03 +01:00
18 changed files with 219 additions and 0 deletions

6
.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
.git
.gitignore
.github
.gitattributes
READMETEMPLATE.md
README.md

20
.editorconfig Normal file
View File

@@ -0,0 +1,20 @@
# This file is globally distributed to all container image projects from
# https://github.com/linuxserver/docker-jenkins-builder/blob/master/.editorconfig
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# trim_trailing_whitespace may cause unintended issues and should not be globally set true
trim_trailing_whitespace = false
[{Dockerfile*,**.yml}]
indent_style = space
indent_size = 2
[{**.sh,root/etc/s6-overlay/s6-rc.d/**,root/etc/cont-init.d/**,root/etc/services.d/**}]
indent_style = space
indent_size = 4

17
.gitattributes vendored Normal file
View File

@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

44
.gitignore vendored Normal file
View File

@@ -0,0 +1,44 @@
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
.jenkins-external

46
Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
FROM ghcr.io/linuxserver/baseimage-ubuntu:jammy
# set version label
ARG BUILD_DATE
ARG VERSION
ARG CODE_RELEASE
LABEL build_version="version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="musabe24"
# environment settings
ARG DEBIAN_FRONTEND="noninteractive"
ENV HOME="/config"
RUN \
echo "**** install runtime dependencies and texlive-full ****" && \
apt-get update && \
apt-get install -y \
git \
jq \
libatomic1 \
nano \
net-tools \
netcat \
texlive-full \
sudo
RUN \
echo "**** install code-server ****" && \
curl -fsSL https://code-server.dev/install.sh | sh && \
echo "**** clean up ****" && \
apt-get clean && \
rm -rf \
/config/* \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*
# add local files
COPY /root /
COPY --chmod=755 install-extensions.sh /usr/local/bin/install-extensions.sh
# ports and volumes
EXPOSE 8443
# Set the default command to run when starting the container
ENTRYPOINT ["install-extensions.sh"]

15
install-extensions.sh Normal file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Die ID der Extension, die installiert werden soll
EXTENSION_ID="james-yu.latex-workshop"
# Überprüfen, ob die Extension bereits installiert ist
if ! code-server --list-extensions | grep -q "${EXTENSION_ID}"; then
echo "Installiere Extension: ${EXTENSION_ID}"
code-server --install-extension ${EXTENSION_ID}
else
echo "Extension ${EXTENSION_ID} ist bereits installiert."
fi
# Starten des code-server
exec code-server --bind-addr 0.0.0.0:8443 --auth none

View File

@@ -0,0 +1,31 @@
#!/usr/bin/with-contenv bash
mkdir -p /config/{extensions,data,workspace,.ssh}
if [ -n "${SUDO_PASSWORD}" ] || [ -n "${SUDO_PASSWORD_HASH}" ]; then
echo "setting up sudo access"
if ! grep -q 'abc' /etc/sudoers; then
echo "adding abc to sudoers"
echo "abc ALL=(ALL:ALL) ALL" >> /etc/sudoers
fi
if [ -n "${SUDO_PASSWORD_HASH}" ]; then
echo "setting sudo password using sudo password hash"
sed -i "s|^abc:\!:|abc:${SUDO_PASSWORD_HASH}:|" /etc/shadow
else
echo "setting sudo password using SUDO_PASSWORD env var"
echo -e "${SUDO_PASSWORD}\n${SUDO_PASSWORD}" | passwd abc
fi
fi
[[ ! -f /config/.bashrc ]] && \
cp /root/.bashrc /config/.bashrc
[[ ! -f /config/.profile ]] && \
cp /root/.profile /config/.profile
# fix permissions (ignore contents of /config/workspace)
find /config -path /config/workspace -prune -o -exec chown abc:abc {} +
chown abc:abc /config/workspace
chmod 700 /config/.ssh
if [ -n "$(ls -A /config/.ssh)" ]; then
chmod 600 /config/.ssh/*
fi

View File

@@ -0,0 +1 @@
oneshot

View File

@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-code-server/run

View File

@@ -0,0 +1 @@
3

View File

@@ -0,0 +1,26 @@
#!/usr/bin/with-contenv bash
if [ -n "${PASSWORD}" ] || [ -n "${HASHED_PASSWORD}" ]; then
AUTH="password"
else
AUTH="none"
echo "starting with no password"
fi
if [ -z ${PROXY_DOMAIN+x} ]; then
PROXY_DOMAIN_ARG=""
else
PROXY_DOMAIN_ARG="--proxy-domain=${PROXY_DOMAIN}"
fi
exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 8443" \
s6-setuidgid abc \
/app/code-server/bin/code-server \
--bind-addr 0.0.0.0:8443 \
--user-data-dir /config/data \
--extensions-dir /config/extensions \
--disable-telemetry \
--auth "${AUTH}" \
"${PROXY_DOMAIN_ARG}" \
"${DEFAULT_WORKSPACE:-/config/workspace}"

View File

@@ -0,0 +1 @@
longrun

View File

@@ -0,0 +1,10 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
_install=(/app/code-server/bin/code-server "--extensions-dir" "/config/extensions" "--install-extension")
if [ "$(whoami)" == "abc" ]; then
"${_install[@]}" "$@"
else
s6-setuidgid abc "${_install[@]}" "$@"
fi