Added code-server docker configuration.
This commit is contained in:
parent
c2f879b918
commit
a997f089e3
121
code-server/code-server.Dockerfile
Normal file
121
code-server/code-server.Dockerfile
Normal file
|
@ -0,0 +1,121 @@
|
|||
FROM ubuntu:noble
|
||||
ARG S6_OVERLAY_VERSION=3.1.6.2
|
||||
|
||||
# set version label
|
||||
#ARG BUILD_DATE
|
||||
#ARG VERSION
|
||||
#ARG CODE_RELEASE
|
||||
#LABEL build_version="daball.me code-server-for-contribs version:- ${VERSION} Build-date:- ${BUILD_DATE}"
|
||||
#LABEL maintainer="daball"
|
||||
|
||||
# Environment settings
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ENV HOME="/config"
|
||||
|
||||
# Set environment variables
|
||||
ENV PUID=1000
|
||||
ARG APT_PACKAGES
|
||||
ARG INSTALL_CONTRIBUTOR_EXTENSIONS
|
||||
ARG INSTALL_DEVELOPER_EXTENSIONS
|
||||
#ENV USER="code"
|
||||
#ENV PASSWORD="password"
|
||||
|
||||
# Install code-server runtime dependencies
|
||||
RUN \
|
||||
echo "**** install runtime dependencies ****" && \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get install -y \
|
||||
git git-lfs bash \
|
||||
jq xz-utils zip unzip tar gzip bzip2 rar 7zip \
|
||||
libatomic1 \
|
||||
nano \
|
||||
net-tools \
|
||||
curl wget \
|
||||
netcat-traditional \
|
||||
sudo dpkg libicu74 equivs $APT_PACKAGES
|
||||
|
||||
RUN equivs-control /tmp/libicu72 && \
|
||||
echo "Section: misc" > /tmp/libicu72 && \
|
||||
echo "Priority: optional" >> /tmp/libicu72 && \
|
||||
echo "Standards-Version: 3.9.2" >> /tmp/libicu72 && \
|
||||
echo "Package: libicu72" >> /tmp/libicu72 && \
|
||||
echo "Provides: libicu74" >> /tmp/libicu72 && \
|
||||
echo "Architecture: all" >> /tmp/libicu72 && \
|
||||
echo "Description: Dummy package for PowerShell." >> /tmp/libicu72
|
||||
RUN equivs-build /tmp/libicu72 && mv libicu72* /tmp
|
||||
RUN dpkg -i /tmp/libicu72*.deb
|
||||
|
||||
ADD https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/powershell_7.4.2-1.deb_amd64.deb /tmp
|
||||
RUN dpkg -i /tmp/powershell_7.4.2-1.deb_amd64.deb
|
||||
#ADD https://github.com/PowerShell/PowerShell/releases/download/v7.5.0-preview.2/powershell-preview_7.5.0-preview.2-1.deb_amd64.deb /tmp
|
||||
#RUN dpkg -i --ignore-depends=libicu72 /tmp/powershell-preview_7.5.0-preview.2-1.deb_amd64.deb
|
||||
RUN apt install -f -y
|
||||
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
|
||||
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
|
||||
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
|
||||
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
|
||||
|
||||
# Install code-server
|
||||
RUN \
|
||||
echo "**** install code-server ****" && \
|
||||
if [ -z ${CODE_RELEASE+x} ]; then \
|
||||
CODE_RELEASE=$(curl -sX GET https://api.github.com/repos/coder/code-server/releases/latest \
|
||||
| awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||'); \
|
||||
fi && \
|
||||
mkdir -p /app/code-server && \
|
||||
curl -o \
|
||||
/tmp/code-server.tar.gz -L \
|
||||
"https://github.com/coder/code-server/releases/download/v${CODE_RELEASE}/code-server-${CODE_RELEASE}-linux-amd64.tar.gz" && \
|
||||
tar xf /tmp/code-server.tar.gz -C \
|
||||
/app/code-server --strip-components=1
|
||||
|
||||
# Do install clean up
|
||||
RUN \
|
||||
echo "**** clean up ****" && \
|
||||
apt-get clean && \
|
||||
rm -rf \
|
||||
/config/* \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
|
||||
# Add user
|
||||
#RUN useradd -m -s /bin/bash -u 1000 -g 1000 -G sudo $USER && echo "$USER:$PASSWORD" | chpasswd
|
||||
|
||||
# Change ownership
|
||||
#RUN chown ubuntu:ubuntu /config
|
||||
|
||||
# Switch user
|
||||
#USER ubuntu
|
||||
#ENV HOME="/config"
|
||||
|
||||
# Install code server extensions
|
||||
RUN for EXT in $INSTALL_CONTRIBUTOR_EXTENSIONS; do \
|
||||
su - ubuntu -c "/app/code-server/bin/code-server --install-extension $EXT"; \
|
||||
done
|
||||
RUN for EXT in $INSTALL_DEVELOPER_EXTENSIONS; do \
|
||||
su - ubuntu -c "/app/code-server/bin/code-server --install-extension $EXT"; \
|
||||
done
|
||||
|
||||
# add local files
|
||||
COPY /root /
|
||||
|
||||
# Expose the necessary port
|
||||
EXPOSE 8443
|
||||
|
||||
# Install Oh-My-ZSH!
|
||||
#RUN chown ubuntu:ubuntu /config
|
||||
#RUN chown ubuntu:ubuntu -R /config/data
|
||||
#RUN chown ubuntu:ubuntu -R /config/extensions
|
||||
#RUN usermod -h /config
|
||||
ADD https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh /tmp/install-oh-my-zsh.sh
|
||||
RUN usermod -s /bin/zsh ubuntu
|
||||
RUN chmod +x /tmp/install-oh-my-zsh.sh && \
|
||||
chown ubuntu:ubuntu /tmp/install-oh-my-zsh.sh && \
|
||||
su - ubuntu -c "echo N|/tmp/install-oh-my-zsh.sh"
|
||||
|
||||
# Start code-server
|
||||
CMD ["su", "-", "ubuntu", "-c", "sh -c '/app/code-server/bin/code-server --bind-addr 0.0.0.0:8443 --auth none'"]
|
99
code-server/config/.bashrc
Normal file
99
code-server/config/.bashrc
Normal file
|
@ -0,0 +1,99 @@
|
|||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||
# for examples
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
[ -z "$PS1" ] && return
|
||||
|
||||
# don't put duplicate lines in the history. See bash(1) for more options
|
||||
# ... or force ignoredups and ignorespace
|
||||
HISTCONTROL=ignoredups:ignorespace
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=1000
|
||||
HISTFILESIZE=2000
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# set variable identifying the chroot you work in (used in the prompt below)
|
||||
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
|
||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||
case "$TERM" in
|
||||
xterm-color) color_prompt=yes;;
|
||||
esac
|
||||
|
||||
# uncomment for a colored prompt, if the terminal has the capability; turned
|
||||
# off by default to not distract the user: the focus in a terminal window
|
||||
# should be on the output of commands, not on the prompt
|
||||
#force_color_prompt=yes
|
||||
|
||||
if [ -n "$force_color_prompt" ]; then
|
||||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||
# We have color support; assume it's compliant with Ecma-48
|
||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
||||
# a case would tend to support setf rather than setaf.)
|
||||
color_prompt=yes
|
||||
else
|
||||
color_prompt=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$color_prompt" = yes ]; then
|
||||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
else
|
||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||
fi
|
||||
unset color_prompt force_color_prompt
|
||||
|
||||
# If this is an xterm set the title to user@host:dir
|
||||
case "$TERM" in
|
||||
xterm*|rxvt*)
|
||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# enable color support of ls and also add handy aliases
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
alias ls='ls --color=auto'
|
||||
#alias dir='dir --color=auto'
|
||||
#alias vdir='vdir --color=auto'
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
fi
|
||||
|
||||
# some more ls aliases
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
# Alias definitions.
|
||||
# You may want to put all your additions into a separate file like
|
||||
# ~/.bash_aliases, instead of adding them here directly.
|
||||
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
||||
|
||||
if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
|
||||
# enable programmable completion features (you don't need to enable
|
||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||
# sources /etc/bash.bashrc).
|
||||
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
||||
# . /etc/bash_completion
|
||||
#fi
|
10
code-server/config/.gitignore
vendored
Normal file
10
code-server/config/.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Ignore local history and user settings
|
||||
.bash_history
|
||||
.cache
|
||||
.config
|
||||
.gitconfig
|
||||
.local
|
||||
.ssh
|
||||
data
|
||||
extensions
|
||||
workspace
|
9
code-server/config/.profile
Normal file
9
code-server/config/.profile
Normal file
|
@ -0,0 +1,9 @@
|
|||
# ~/.profile: executed by Bourne-compatible login shells.
|
||||
|
||||
if [ "$BASH" ]; then
|
||||
if [ -f ~/.bashrc ]; then
|
||||
. ~/.bashrc
|
||||
fi
|
||||
fi
|
||||
|
||||
mesg n 2> /dev/null || true
|
35
code-server/docker-compose.yml
Normal file
35
code-server/docker-compose.yml
Normal file
|
@ -0,0 +1,35 @@
|
|||
services:
|
||||
code-server:
|
||||
image: nm3clol/code-server
|
||||
build:
|
||||
# context: ../../
|
||||
dockerfile: ./code-server.Dockerfile
|
||||
args:
|
||||
APT_PACKAGES: "git-lfs git-filter-repo zsh fish"
|
||||
INSTALL_CONTRIBUTOR_EXTENSIONS: "mhutchie.git-graph yzhang.markdown-all-in-one mechatroner.rainbow-csv"
|
||||
INSTALL_DEVELOPER_EXTENSIONS: ""
|
||||
container_name: code-server
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PUID=1000
|
||||
- TZ=America/New_York
|
||||
# - PASSWORD=password
|
||||
# - HASHED_PASSWORD=
|
||||
# - SUDO_PASSWORD=password
|
||||
# - SUDO_PASSWORD_HASH=
|
||||
# - PROXY_DOMAIN=code-server.my.domain
|
||||
- DEFAULT_WORKSPACE=/config/workspace
|
||||
networks:
|
||||
- code-server
|
||||
volumes:
|
||||
- ./config:/config
|
||||
- ../..:/config/workspace
|
||||
- $HOME/.ssh:/root/.ssh
|
||||
ports:
|
||||
- 8443:8443
|
||||
restart: unless-stopped
|
||||
#volumes:
|
||||
# code-config:
|
||||
# dev-volume:
|
||||
networks:
|
||||
code-server:
|
31
code-server/root/etc/s6-overlay/s6-rc.d/init-code-server/run
Executable file
31
code-server/root/etc/s6-overlay/s6-rc.d/init-code-server/run
Executable 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
|
|
@ -0,0 +1 @@
|
|||
oneshot
|
|
@ -0,0 +1 @@
|
|||
/etc/s6-overlay/s6-rc.d/init-code-server/run
|
|
@ -0,0 +1 @@
|
|||
3
|
26
code-server/root/etc/s6-overlay/s6-rc.d/svc-code-server/run
Executable file
26
code-server/root/etc/s6-overlay/s6-rc.d/svc-code-server/run
Executable 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}"
|
|
@ -0,0 +1 @@
|
|||
longrun
|
10
code-server/root/usr/local/bin/install-extension
Executable file
10
code-server/root/usr/local/bin/install-extension
Executable 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
|
Loading…
Reference in New Issue
Block a user