Skip to content

Commit

Permalink
🐛 add new bashrc + node 21
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Oct 18, 2023
1 parent 9f82f3f commit e094f7f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
42 changes: 27 additions & 15 deletions .additional_bashrc.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e094f7f

Please sign in to comment.