From 2d8c83df82ae3ad56f932665a4cd77a851029311 Mon Sep 17 00:00:00 2001 From: Jakob Busk Date: Fri, 19 Nov 2021 12:44:22 +0000 Subject: [PATCH] More dep installed, added zsh (oh-my-zsh) --- .zshrc | 119 ++++++++++++++++++++++++++++ Dockerfile | 92 +++++++++++++++++++-- Dockerfile.nvm | 53 +++++++++++++ Dockerfile.old | 67 ++++++++++++++++ root/etc/cont-init.d/30-config | 99 +++++++++++++++++++++-- root/etc/services.d/code-server/run | 26 +++--- 6 files changed, 433 insertions(+), 23 deletions(-) create mode 100644 .zshrc create mode 100644 Dockerfile.nvm create mode 100644 Dockerfile.old diff --git a/.zshrc b/.zshrc new file mode 100644 index 00000000..f3cd9e7f --- /dev/null +++ b/.zshrc @@ -0,0 +1,119 @@ +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# Laravel +export PATH=~/.composer/vendor/bin:$PATH + + +# # wrk http tester +alias wrk="~/dev/cli/wrk/wrk" + +# The next line updates PATH for the Google Cloud SDK. +if [ -f "$HOME/.dotfiles/google-cloud-sdk/path.zsh.inc" ]; then . "$HOME/.dotfiles/google-cloud-sdk/path.zsh.inc"; fi + +# The next line enables shell command completion for gcloud. +if [ -f "$HOME/.dotfiles/google-cloud-sdk/completion.zsh.inc" ]; then . "$HOME/.dotfiles/google-cloud-sdk/completion.zsh.inc"; fi + + +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:/usr/local/bin:$PATH + +# Path to your oh-my-zsh installation. +export ZSH="$HOME/.oh-my-zsh" + +# Set name of the theme to load --- if set to "random", it will +# load a random theme each time oh-my-zsh is loaded, in which case, +# to know which specific one was loaded, run: echo $RANDOM_THEME +# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes +ZSH_THEME="robbyrussell" + +# Set list of themes to pick from when loading at random +# Setting this variable when ZSH_THEME=random will cause zsh to load +# a theme from this variable instead of looking in $ZSH/themes/ +# If set to an empty array, this variable will have no effect. +# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to use hyphen-insensitive completion. +# Case-sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +# Uncomment the following line to disable bi-weekly auto-update checks. +# DISABLE_AUTO_UPDATE="true" + +# Uncomment the following line to automatically update without prompting. +# DISABLE_UPDATE_PROMPT="true" + +# Uncomment the following line to change how often to auto-update (in days). +# export UPDATE_ZSH_DAYS=13 + +# Uncomment the following line if pasting URLs and other text is messed up. +# DISABLE_MAGIC_FUNCTIONS="true" + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work) +# See https://github.com/ohmyzsh/ohmyzsh/issues/5765 +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# You can set one of the optional three formats: +# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +# or set a custom format using the strftime function format specifications, +# see 'man strftime' for details. +# HIST_STAMPS="mm/dd/yyyy" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? +# Standard plugins can be found in $ZSH/plugins/ +# Custom plugins may be added to $ZSH_CUSTOM/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=(git github gitignore) + +source $ZSH/oh-my-zsh.sh + +# User configuration + +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi + +# Compilation flags +# export ARCHFLAGS="-arch x86_64" + +# Set personal aliases, overriding those provided by oh-my-zsh libs, +# plugins, and themes. Aliases can be placed here, though oh-my-zsh +# users are encouraged to define aliases within the ZSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" diff --git a/Dockerfile b/Dockerfile index 6e6a0243..c958b9b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,23 @@ +# CHANGE TO FOCAL FROM ghcr.io/linuxserver/baseimage-ubuntu:bionic # set version label -ARG BUILD_DATE -ARG VERSION -ARG CODE_RELEASE -LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" -LABEL maintainer="aptalca" +LABEL maintainer="Jakob Busk " +LABEL name="code-server on Docker" +LABEL version="latest" # environment settings -ENV HOME="/config" +ENV HOME="/home" + +RUN apt-get update +RUN apt install -y zsh wget curl sudo +RUN touch /home/.zshrc + +RUN chown -R abc:abc /home +USER abc +RUN /bin/zsh /home/.zshrc + +USER root RUN \ echo "**** install node repo ****" && \ @@ -63,5 +72,74 @@ RUN \ # add local files COPY /root / +RUN sudo apt update +RUN sudo apt -y install software-properties-common +RUN add-apt-repository -y ppa:ondrej/php +RUN sudo apt update +RUN sudo apt -y install composer \ + php8.0 \ + php8.0-dev \ + php8.0-bcmath \ + php8.0-ctype \ + php8.0-curl \ + php8.0-gd \ + php8.0-intl \ + php8.0-mbstring \ + php8.0-mysql \ + php8.0-pgsql \ + php8.0-sqlite3 \ + php8.0-tokenizer \ + php8.0-xml \ + php8.0-zip + +RUN echo "**** install php7.4 ****" +RUN apt update && \ + apt install -y \ + php7.4 \ + php7.4-xml \ + php7.4-mongodb \ + php7.4-mysql \ + php7.4-imagick \ + php7.4-imap \ + php7.4-fpm \ + php7.4-cli \ + php7.4-bcmath \ + php7.4-mbstring + +RUN echo "**** install php8.1 ****" +RUN apt update && \ + apt install -y \ + php8.1 \ + php8.1-xml \ + php8.1-mongodb \ + php8.1-mysql \ + php8.1-imagick \ + php8.1-imap \ + php8.1-fpm \ + php8.1-cli \ + php8.1-bcmath \ + php8.1-mbstring + +RUN sudo apt update +RUN sudo apt install -y git zip unzip build-essential libssl-dev libffi-dev python3-dev python3.8 lsof -y +RUN sudo apt-get install -y apt-transport-https ca-certificates gnupg + +# Install google cli tools +RUN sudo npm install -g firebase-tools +RUN sudo apt-get install -y apt-transport-https ca-certificates gnupg +RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list +RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - +RUN sudo apt-get update && sudo apt-get install -y \ + google-cloud-sdk \ + google-cloud-sdk-datastore-emulator \ + google-cloud-sdk-cloud-build-local \ + google-cloud-sdk-pubsub-emulator + +# RUN sudo apt update +# RUN sudo apt install -y docker docker-compose + # ports and volumes -EXPOSE 8443 +EXPOSE 2999-9000 +RUN sudo usermod --shell /bin/zsh abc + +COPY ./.zshrc /home \ No newline at end of file diff --git a/Dockerfile.nvm b/Dockerfile.nvm new file mode 100644 index 00000000..4a2db2a0 --- /dev/null +++ b/Dockerfile.nvm @@ -0,0 +1,53 @@ +FROM ubuntu:focal + +# set version label +LABEL maintainer="Jakob Busk " +LABEL name="code-server on Docker" +LABEL version="latest" + +# environment settings +ENV HOME="/home" +ENV WORKSPACE="/workspace" + +# Install development dependencies +# Install NVM and node 13, 14, 15, 16 +RUN echo "**** install nvm ****" && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash + +# We use latest major version of Node.js distributed VS Code. (see about dialog in your local VS Code) +RUN bash -c "nvm install 13 \ + && nvm install 14 \ + && nvm install 15 \ + && nvm install 16 \ + && nvm use 16 \ + && nvm alias default 16" + + +# RUN echo "**** install code-server ****" && \ +# if [ -z ${CODE_RELEASE+x} ]; then \ +# CODE_RELEASE=$(curl -sX GET https://registry.yarnpkg.com/code-server \ +# | jq -r '."dist-tags".latest' | sed 's|^|v|'); \ +# fi && \ +# CODE_VERSION=$(echo "$CODE_RELEASE" | awk '{print substr($1,2); }') && \ +# yarn config set network-timeout 600000 -g && \ +# yarn --production --verbose --frozen-lockfile global add code-server@"$CODE_VERSION" && \ +# yarn cache clean && \ +# echo "**** clean up ****" && \ +# apt-get purge --auto-remove -y \ +# build-essential \ +# libx11-dev \ +# libxkbfile-dev \ +# libsecret-1-dev \ +# pkg-config && \ +# apt-get clean && \ +# rm -rf \ +# /tmp/* \ +# /var/lib/apt/lists/* \ +# /var/tmp/* + +# add local files +COPY /root / + +# ports and volumes +EXPOSE 2999 +EXPOSE 3000-9999 \ No newline at end of file diff --git a/Dockerfile.old b/Dockerfile.old new file mode 100644 index 00000000..6e6a0243 --- /dev/null +++ b/Dockerfile.old @@ -0,0 +1,67 @@ +FROM ghcr.io/linuxserver/baseimage-ubuntu:bionic + +# set version label +ARG BUILD_DATE +ARG VERSION +ARG CODE_RELEASE +LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" +LABEL maintainer="aptalca" + +# environment settings +ENV HOME="/config" + +RUN \ + echo "**** install node repo ****" && \ + apt-get update && \ + apt-get install -y \ + gnupg && \ + curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \ + echo 'deb https://deb.nodesource.com/node_14.x bionic main' \ + > /etc/apt/sources.list.d/nodesource.list && \ + curl -s https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ + echo 'deb https://dl.yarnpkg.com/debian/ stable main' \ + > /etc/apt/sources.list.d/yarn.list && \ + echo "**** install build dependencies ****" && \ + apt-get update && \ + apt-get install -y \ + build-essential \ + libx11-dev \ + libxkbfile-dev \ + libsecret-1-dev \ + pkg-config && \ + echo "**** install runtime dependencies ****" && \ + apt-get install -y \ + git \ + jq \ + nano \ + net-tools \ + nodejs \ + sudo \ + yarn && \ + echo "**** install code-server ****" && \ + if [ -z ${CODE_RELEASE+x} ]; then \ + CODE_RELEASE=$(curl -sX GET https://registry.yarnpkg.com/code-server \ + | jq -r '."dist-tags".latest' | sed 's|^|v|'); \ + fi && \ + CODE_VERSION=$(echo "$CODE_RELEASE" | awk '{print substr($1,2); }') && \ + yarn config set network-timeout 600000 -g && \ + yarn --production --verbose --frozen-lockfile global add code-server@"$CODE_VERSION" && \ + yarn cache clean && \ + echo "**** clean up ****" && \ + apt-get purge --auto-remove -y \ + build-essential \ + libx11-dev \ + libxkbfile-dev \ + libsecret-1-dev \ + pkg-config && \ + apt-get clean && \ + rm -rf \ + /tmp/* \ + /var/lib/apt/lists/* \ + /var/tmp/* + +# add local files +COPY /root / + +# ports and volumes +EXPOSE 8443 diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index 1c09036b..9cd62aa9 100644 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -1,6 +1,15 @@ #!/usr/bin/with-contenv bash -mkdir -p /config/{extensions,data,workspace,.ssh} +mkdir /home/workspace +mkdir /home/.ssh +mkdir /home/.config/extensions +mkdir /home/.config/data + +# if [ -z ${USER} ]; then +# CODE_USER="--bind-addr=0.0.0.0:2999" +# else +# CODE_USER="--bind-addr 0.0.0.0:${CODE_PORT}" +# fi if [ -n "${SUDO_PASSWORD}" ] || [ -n "${SUDO_PASSWORD_HASH}" ]; then echo "setting up sudo access" @@ -23,15 +32,95 @@ if [ -f "/usr/bin/find" ] && [ -f "/usr/bin/xargs" ]; then # Split workload between config and workspace echo "setting permissions::configuration" - find /config -path /config/workspace -prune -false -o -type d -print0 | \ + find /home -path /home/.config -prune -false -o -type d -print0 | \ xargs --null -r --max-args=1 --max-procs=$((CORES*2*8)) \ chown -R abc:abc echo "setting permissions::workspace" - chown abc:abc /config/workspace + chown abc:abc /home/workspace else # Set permissions on data mount # do not decend into the workspace - chown -R abc:abc "$(ls /config -I workspace)" - chown abc:abc /config/workspace + chown -R abc:abc "$(ls /home -I workspace)" + chown abc:abc /home fi + + +sudo sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +sudo zsh +git clone https://github.com/wg/wrk.git /home/.cli/wrk +cd /home/.cli/wrk +sudo make +cd /home +git clone https://github.com/nvm-sh/nvm.git .nvm +cd ~/.nvm && git checkout v0.39.0 +. ./nvm.sh + +cat << 'EOF' > /home/.zshrc +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# Laravel +export PATH=~/.composer/vendor/bin:$PATH + +#Kill port +function killport() { + if [ "$1" != "" ] + then + kill -9 $(lsof -t -i:$1) + else + echo Choose a port + fi # closing statement of if-else block +} + +# # wrk http tester +alias wrk="$HOME/.cli/wrk/wrk" + +# The next line updates PATH for the Google Cloud SDK. +if [ -f "$HOME/.dotfiles/google-cloud-sdk/path.zsh.inc" ]; then . "$HOME/.dotfiles/google-cloud-sdk/path.zsh.inc"; fi + +# The next line enables shell command completion for gcloud. +if [ -f "$HOME/.dotfiles/google-cloud-sdk/completion.zsh.inc" ]; then . "$HOME/.dotfiles/google-cloud-sdk/completion.zsh.inc"; fi + + +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:/usr/local/bin:$PATH + +# Path to your oh-my-zsh installation. +export ZSH="$HOME/.oh-my-zsh" + +# Set name of the theme to load --- if set to "random", it will +# load a random theme each time oh-my-zsh is loaded, in which case, +# to know which specific one was loaded, run: echo $RANDOM_THEME +# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes +ZSH_THEME="robbyrussell" +plugins=(git github gitignore) + +EOF +/bin/zsh | nvm install 12 +/bin/zsh | nvm install 13 +/bin/zsh | nvm install 14 +/bin/zsh | nvm install 15 +/bin/zsh | nvm install 16 +/bin/zsh | nvm install 17 + +# # Install NPM globals +npm install --global @gridsome/cli +npm install -g firebase-tools +npm i -g nodemon +npm install -g yarn +npm install -g npx + +# # linting +npm install -g eslint +npm install -g babel-eslint +npm install -g eslint-config-standard +npm install -g eslint-plugin-react +npm install -g eslint-config-prettier +npm install -g eslint-plugin-prettier +npm install -g prettier +npm install -g standard +npm install -g typescript + +sudo usermod --shell /bin/zsh abc \ No newline at end of file diff --git a/root/etc/services.d/code-server/run b/root/etc/services.d/code-server/run index c298a9b4..5cdff8db 100644 --- a/root/etc/services.d/code-server/run +++ b/root/etc/services.d/code-server/run @@ -1,7 +1,7 @@ #!/usr/bin/with-contenv bash if [ -n "${PASSWORD}" ] || [ -n "${HASHED_PASSWORD}" ]; then - AUTH="password" + AUTH="${PASSWORD}" else AUTH="none" echo "starting with no password" @@ -13,13 +13,17 @@ else PROXY_DOMAIN_ARG="--proxy-domain=${PROXY_DOMAIN}" fi -exec \ - s6-setuidgid abc \ - /usr/local/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}" \ - /config/workspace +if [ -z ${CODE_PORT} ]; then + CODE_PORT_ARG="--bind-addr=0.0.0.0:2999" +else + CODE_PORT_ARG="--bind-addr 0.0.0.0:${CODE_PORT}" +fi + +/usr/local/bin/code-server \ + "${CODE_PORT_ARG}" \ + --user-data-dir /home/.config/data \ + --extensions-dir /home/.config/extensions \ + --disable-telemetry \ + --auth "${AUTH}" \ + "${PROXY_DOMAIN_ARG}" \ + /home/workspace