From e094f7f69b701b836c8d5d53107bf5cbd5e5afb6 Mon Sep 17 00:00:00 2001 From: Matthias Vogel Date: Wed, 18 Oct 2023 09:07:09 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20add=20new=20bashrc=20+=20node=20?= =?UTF-8?q?21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .additional_bashrc.sh | 42 ++++++++++++++++++++++++-------------- .github/workflows/main.yml | 6 +++++- Dockerfile | 10 ++++----- README.md | 6 +++++- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/.additional_bashrc.sh b/.additional_bashrc.sh index 3f8019b..62b2f74 100644 --- a/.additional_bashrc.sh +++ b/.additional_bashrc.sh @@ -1,27 +1,39 @@ export LS_COLORS="${LS_COLORS}di=1;34:" -export EXA_COLORS="da=1;34:gm=1;34" -#alias ls='exa' alias ll='ls -alh' -export PATH=$PATH:~/.composer/vendor/bin:./bin:./vendor/bin:./node_modules/.bin:~/.yarn/bin -source ~/.git-completion.bash -source ~/.git-prompt.sh +export PATH=$PATH:~/.config/composer/vendor/bin:~/.composer/vendor/bin:./bin:./vendor/bin:./node_modules/.bin:~/.yarn/bin -#CONTAINER_ID=$(basename $(cat /proc/1/cpuset)) -#export HOST_DISPLAY_NAME=$HOSTNAME -#if sudo docker ps -q &>/dev/null; then -# DOCKER_COMPOSE_PROJECT=$(sudo docker inspect ${CONTAINER_ID} | grep '"com.docker.compose.project":' | awk '{print $2}' | tr --delete '"' | tr --delete ',') -# export HOST_DISPLAY_NAME=$(sudo docker inspect ${CONTAINER_ID} --format='{{.Name}}') -# export HOST_DISPLAY_NAME=${HOST_DISPLAY_NAME:1} -#fi; +# only enable docker aliases if docker-socket is mounted +CONTAINER_ID=$(basename $(findmnt /etc/hosts -o SOURCE | grep -o 'containers\/.\+\/')) +export HOST_DISPLAY_NAME=$HOSTNAME +if sudo docker ps -q &>/dev/null; then + DOCKER_COMPOSE_PROJECT=$(sudo docker inspect ${CONTAINER_ID} | jq -r '.[0].Config.Labels."com.docker.compose.project"') + export NODE_CONTAINER=$(sudo docker ps -f "name=${DOCKER_COMPOSE_PROJECT}" --format {{.Names}} | grep node) + export HOST_DISPLAY_NAME=$(sudo docker inspect ${CONTAINER_ID} --format='{{.Name}}') + export HOST_DISPLAY_NAME=${HOST_DISPLAY_NAME:1} +fi; + +export HISTCONTROL=ignoreboth:erasedups if [[ $CONTAINER_ID != ${HOSTNAME}* ]] ; then export HOST_DISPLAY_NAME=$HOSTNAME -fi; +fi -PS1='\033]2;'$(pwd)'\007\[\e[0;36m\][\[\e[1;31m\]\u\[\e[0;36m\]@\[\e[1;34m\]$HOST_DISPLAY_NAME\[\e[0;36m\]: \[\e[0m\]\w\[\e[0;36m\]]\[\e[0m\]\$\[\e[1;32m\]\s\[\e[0;33m\]$(__git_ps1)\[\e[0;36m\]> \[\e[0m\]\n$ '; +source ~/.bash_git + +PS1='\033]2;$HOST_DISPLAY_NAME: \w\007\[\e[0;36m\][\[\e[1;31m\]\u\[\e[0;36m\]@\[\e[1;34m\]$HOST_DISPLAY_NAME\[\e[0;36m\]: \[\e[0m\]\w\[\e[0;36m\]]\[\e[0m\]\$\[\e[1;32m\]\s\[\e[0;33m\]$(__git_ps1)\[\e[0;36m\]> \[\e[0m\]\n$ '; # Run SSH Agent and add key 7d if [ -z "$SSH_AUTH_SOCK" ] ; then eval `ssh-agent -s` + if [ -f ~/.ssh/id_rsa ]; then ssh-add -t 604800 ~/.ssh/id_rsa -fi; + fi + if [ -f ~/.ssh/id_ed25519 ]; then + ssh-add -t 604800 ~/.ssh/id_ed25519 + fi +fi + +if [ -v VIRTUAL_HOST ] ; then + echo 'Frontend URLs:' + echo $VIRTUAL_HOST | tr "," "\n" | awk '{print " https://" $0}' +fi \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 63e8421..0688f64 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,11 @@ jobs: - node: 18 tags: "ghcr.io/pluswerk/node-dev:lts,ghcr.io/pluswerk/node-dev:18,pluswerk/node-dev:lts,pluswerk/node-dev:18" - node: 19 - tags: "ghcr.io/pluswerk/node-dev,ghcr.io/pluswerk/node-dev:current,ghcr.io/pluswerk/node-dev:19,pluswerk/node-dev,pluswerk/node-dev:current,pluswerk/node-dev:19" + tags: "ghcr.io/pluswerk/node-dev:19,pluswerk/node-dev:19" + - node: 20 + tags: "ghcr.io/pluswerk/node-dev:20,pluswerk/node-dev:20" + - node: 21 + tags: "ghcr.io/pluswerk/node-dev,ghcr.io/pluswerk/node-dev:current,ghcr.io/pluswerk/node-dev:21,pluswerk/node-dev,pluswerk/node-dev:current,pluswerk/node-dev:21" steps: - name: Set up QEMU diff --git a/Dockerfile b/Dockerfile index 63c66d3..8863fa0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,16 +4,14 @@ FROM $FROM ENV PATH=$PATH:./node_modules/.bin RUN apt-get update && \ - apt-get install -y sudo vim nano less tree bash-completion mariadb-client iputils-ping sshpass && \ + apt-get install -y sudo vim nano less tree bash-completion mariadb-client iputils-ping sshpass gdb jq && \ usermod -aG sudo node && \ echo "node ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + curl -fsSL https://get.docker.com/ | sh && \ rm -rf /var/lib/apt/lists/* COPY .additional_bashrc.sh /home/node/.additional_bashrc.sh COPY .vimrc /home/node/.vimrc COPY .vimrc /home/root/.vimrc -RUN echo "source ~/.additional_bashrc.sh" >> /home/node/.bashrc - -# add .git-completion.bash and .git-prompt.bash -RUN curl https://raw.githubusercontent.com/git/git/v$(git --version | awk 'NF>1{print $NF}')/contrib/completion/git-completion.bash > /home/node/.git-completion.bash && \ - curl https://raw.githubusercontent.com/git/git/v$(git --version | awk 'NF>1{print $NF}')/contrib/completion/git-prompt.sh > /home/node/.git-prompt.sh +RUN echo "source ~/.additional_bashrc.sh" >> /home/node/.bashrc && \ + curl -L https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > /home/node/.bash_git diff --git a/README.md b/README.md index 5cd1958..2748f9d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ NODE-DEV is a small package that adds some tools to ease the development inside It is derived from [pluswerk/php-dev](https://github.com/pluswerk/php-dev/) and includes `git`, `ssh`, `vim`, `nano`, `ping`, `mysql`, `mysqldump`, and autocomplete for `git` -It comes with versions for: `current`/`19`, `lts`/`18`, `17`, `16`, `15`, `14`, `13` and `12`. +It comes with versions for: `current`/`21`, `20`, `19`, `lts`/`18`, `17`, `16`, `15`, `14`, `13` and `12`. # example docker-compose.yml ````yml @@ -15,6 +15,10 @@ services: image: ghcr.io/pluswerk/node-dev:lts volumes: - ./:/app + # the docker socket is optional if no node container is needed + - /var/run/docker.sock:/var/run/docker.sock:ro + - ~/.ssh:/home/node/.ssh + - ~/.gitconfig:/home/node/.gitconfig working_dir: /app environment: # Don't forget to connect via bash start.sh