main #1

Merged
daball merged 5 commits from daball/nm3clol-docker:main into main 2024-06-25 00:32:33 -04:00
21 changed files with 431 additions and 0 deletions
Showing only changes of commit 96041a7d40 - Show all commits

View File

@ -0,0 +1,129 @@
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"
ENV TZ="${TZ-America/New_York}"
# 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 tzdata $APT_PACKAGES
# Set timezone
RUN \
echo $TZ > /etc/timezone && \
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata
# Build dummy package for Microsoft PowerShell
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'"]

View 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
View File

@ -0,0 +1,10 @@
# Ignore local history and user settings
.bash_history
.cache
.config
.gitconfig
.local
.ssh
data
extensions
workspace

View 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

View 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 httrack"
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:

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,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

View File

@ -0,0 +1,14 @@
FROM ubuntu:noble
ARG DEBIAN_FRONTEND="noninteractive"
ARG GIT_REPO_URL=""
ENV TZ="${TZ-America/New_York}"
WORKDIR /archived
VOLUME /archived
USER ubuntu
RUN sh -c
CMD ["httrack "]

View File

@ -0,0 +1,6 @@
#!/bin/sh
REPO_DIR="../../nm3clol-archived-russellcountyida.org"
URLS="https://russellcountyida.org/ https://www.russellcountyida.org/" \
MIRROR_DIR="mirror" \
./sync-website-archive.sh

View File

@ -0,0 +1,6 @@
#!/bin/sh
REPO_DIR="../../nm3clol-archived-russellcountyva.us" \
URLS="https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2024\&endDate=12/31/2024\&dateRange=\&dateSelector= https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2023\&endDate=12/31/2023\&dateRange=\&dateSelector= https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2022\&endDate=12/31/2022\&dateRange=\&dateSelector= https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2021\&endDate=12/31/2021\&dateRange=\&dateSelector= https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2020\&endDate=12/31/2020\&dateRange=\&dateSelector= https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2019\&endDate=12/31/2019\&dateRange=\&dateSelector= https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2018\&endDate=12/31/2018\&dateRange=\&dateSelector= https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2017\&endDate=12/31/2017\&dateRange=\&dateSelector= https://www.russellcountyva.us/AgendaCenter/Search/?term=\&CIDs=all\&startDate=01/01/2016\&endDate=12/31/2016\&dateRange=\&dateSelector= https://www.russellcountyva.us/" \
MIRROR_DIR="mirror" \
./sync-website-archive.sh

View File

@ -0,0 +1,52 @@
#!/bin/sh
echo REPO_DIR=$REPO_DIR
echo REPO_URL=$REPO_URL
echo URLS=$URLS
echo OPEN_PWD=$(pwd)
cd $REPO_DIR
if [ "$(ls -A $REPO_DIR)" ]; then
git pull
# echo httrack --update
else
git clone $REPO_URL .
fi;
rm -rf ./mirror
httrack -wqiC2%Ps0u1%s%uN0%Ip3DaK0H1%kf2A125000%f#f -%F "<!-- Mirrored from %s%s by HTTrack Website Copier/3.x [XR&CO'2014], %s -->" -%l "en, *" $URLS -O1 ./mirror +*.png +*.gif +*.jpg +*.jpeg +*.css +*.js +*.pdf +*.doc +*.docx +*.xls +*.xlsx +*.csv +*.odt +*.ppt +*.pptx +*.epub +*.webp +*.webm +*.mkv +*.mpg +*.mpeg +*.mov +*.wav +*.mp3 -mime:application/*
git add ./mirror/
MESSAGE="$(cat ./mirror/hts-log.txt | head -n 1 | sed -E 's/(.*) at .*/\"Synced with \1.\"/g')"
git commit -m "$MESSAGE"
DATE_YEAR="$(echo $MESSAGE | sed -E 's/.* on [[:alpha:]]+, [[:digit:]]+ [[:alpha:]]+ ([[:digit:]]+).*/\1/g')"
DATE_MONTH="$(echo $MESSAGE | sed -E 's/.* on [[:alpha:]]+, [[:digit:]]+ ([[:alpha:]]+).*/\1/g')"
case "$(echo $MESSAGE | sed -E 's/.* on [[:alpha:]]+, [[:digit:]]+ ([[:alpha:]]+).*/\1/g')" in
Jan) DATE_MONTH="01" ;;
Feb) DATE_MONTH="02" ;;
Mar) DATE_MONTH="03" ;;
Apr) DATE_MONTH="04" ;;
May) DATE_MONTH="05" ;;
Jun) DATE_MONTH="06" ;;
Jul) DATE_MONTH="07" ;;
Aug) DATE_MONTH="08" ;;
Sep) DATE_MONTH="09" ;;
Oct) DATE_MONTH="10" ;;
Nov) DATE_MONTH="11" ;;
Dec) DATE_MONTH="12" ;;
esac
DATE_DAY="$(echo $MESSAGE | sed -E 's/.* on [[:alpha:]]+, ([[:digit:]]+).*/\1/g')"
DATE_HOUR="$(echo $MESSAGE | sed -E 's/.* on [[:alpha:]]+, [[:digit:]]+ [[:alpha:]]+ [[:digit:]]+ ([[:digit:]]+).*/\1/g')"
DATE_MINUTE="$(echo $MESSAGE | sed -E 's/.* on [[:alpha:]]+, [[:digit:]]+ [[:alpha:]]+ [[:digit:]]+ [[:digit:]]+:([[:digit:]]+).*/\1/g')"
DATE_SECOND="$(echo $MESSAGE | sed -E 's/.* on [[:alpha:]]+, [[:digit:]]+ [[:alpha:]]+ [[:digit:]]+ [[:digit:]]+:[[:digit:]]+:([[:digit:]]+).*/\1/g')"
VERSION_TAG_DATE="$DATE_YEAR-$DATE_MONTH-$DATE_DAY-$DATE_HOUR-$DATE_MINUTE-$DATE_SECOND"
MOST_RECENT_COMMIT="$(git rev-parse HEAD)"
git tag $VERSION_TAG_DATE $MOST_RECENT_COMMIT
git push --all
git push --tags
cd $OPEN_PWD