Merge branch 'master' of github.com:sabrehagen/desktop-environment

This commit is contained in:
Jackson Delahunt 2019-01-15 11:22:27 +11:00
commit c4ae4c95be
6 changed files with 71 additions and 37 deletions

View file

@ -20,7 +20,7 @@ RUN groupmod \
# Rename the first non-root user to jackson
RUN usermod \
--home $HOME \
--groups docker \
--groups $USER,docker \
--login $USER \
--move-home \
$BASE_USER
@ -49,7 +49,7 @@ RUN apt update && apt install --yes \
# Add user to groups required to run chrome
RUN groupadd --system chrome && \
usermod --groups audio,chrome,video $USER
usermod --append --groups audio,chrome,video $USER
# Install vs code
RUN echo 'deb http://au.archive.ubuntu.com/ubuntu/ xenial main restricted universe' > /etc/apt/sources.list && \
@ -70,24 +70,6 @@ RUN apt install --yes \
# Enable password-less sudo for user
RUN echo "$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Clear and re-cache zsh plugins
RUN zsh -c "source antigen.zsh; antigen reset; source $HOME/.zshrc"
# Clone dotfiles configuration
RUN alias https-to-git="sed 's;https://github.com/\(.*\);git@github.com:\1.git;'"
RUN git clone https://github.com/sabrehagen/dotfiles-alacritty
RUN git clone https://github.com/sabrehagen/dotfiles-code
RUN git clone https://github.com/sabrehagen/dotfiles-git
RUN git clone https://github.com/sabrehagen/dotfiles-scripts
RUN git clone https://github.com/sabrehagen/dotfiles-tmux
RUN git clone https://github.com/sabrehagen/dotfiles-vcsh
RUN git clone https://github.com/sabrehagen/dotfiles-zsh
# Add program configurations
COPY config/tmuxinator $HOME/.config/tmuxinator
COPY config/zsh/.zshenv $HOME/.zshenv.desktop
RUN sed -i '1s;^;source $HOME/.zshenv.desktop\n\n;' $HOME/.zshenv
# Add custom binaries
COPY bin /usr/local/bin
@ -105,5 +87,19 @@ ENV CONTAINER_IMAGE_NAME sabrehagen/desktop-environment
USER $USER
WORKDIR $HOME
# Remove base container configuration and clone dotfiles configuration
RUN alias https-to-git="sed 's;https://github.com/\(.*\);git@github.com:\1.git;'"
RUN vcsh clone https://github.com/sabrehagen/dotfiles-alacritty && \
vcsh clone https://github.com/sabrehagen/dotfiles-code && \
vcsh clone https://github.com/sabrehagen/dotfiles-scripts
# Add program configurations
COPY config/tmuxinator $HOME/.config/tmuxinator
COPY config/zsh/.zshenv $HOME/.zshenv.desktop
RUN sed -i '1s;^;source $HOME/.zshenv.desktop\n\n;' $HOME/.zshenv
# Clear and re-cache zsh plugins
RUN zsh -c "source antigen.zsh; antigen reset; source $HOME/.zshrc"
# Start the long-lived tmux session
CMD zsh -c "tmux new-session -d -s $STEMN_TMUX_SESSION && sleep infinity"
CMD zsh

View file

@ -4,4 +4,7 @@ touch $CONTAINER_TMUX_SOCKET
alias tmux="tmux -u -S $CONTAINER_TMUX_SOCKET"
# Change to the most frequently used directory
cd $HOME/repositories/stemn/stemn-backend
STARTUP_DIR=$HOME/repositories/stemn/stemn-backend
if [ -d $STARTUP_DIR ]; then
cd $STARTUP_DIR
fi

View file

@ -1,28 +1,51 @@
# Script is run as root to create the host user
if [ $USER != "root" ]; then
echo "Host configuration script must be run as root!"
exit 1
fi
# Host user configuration
HOST_USER=$(whoami)
HOST_HOME=$HOME
HOST_USER=jackson
HOST_USER_ID=1000
HOST_HOME=/$HOST_USER/home
# Container user configuration
CONTAINER_USER=jackson
CONTAINER_HOME=/$CONTAINER_USER/home
# Make the host user home directory
mkdir -p $HOST_HOME
# Install docker on the host
apt update && apt install --yes \
docker.io
# Create the host user group
groupadd \
--gid $HOST_USER_ID \
$HOST_USER
# Add the container user to the docker group on the host
usermod -aG docker $CONTAINER_USER
# Create the host user
useradd \
--gid $HOST_USER_ID \
--uid $HOST_USER_ID \
$HOST_USER
# Add the host user to the docker group
usermod -aG docker $HOST_USER
# Allow connections from docker containers to the host's X server
xhost local:docker
# Enable password-less sudo for the container user on the host
echo "$HOST_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers
# Install utilities
apt update && apt install --yes && \
docker.io && \
vcsh
# Enable password-less sudo for the host user
echo "$HOST_USER ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers
# Install alacritty on the host
wget -q -O alacritty.deb https://github.com/jwilm/alacritty/releases/download/v0.2.5/Alacritty-v0.2.5_amd64.deb && \
wget -O alacritty.deb https://github.com/jwilm/alacritty/releases/download/v0.2.5/Alacritty-v0.2.5_amd64.deb && \
dpkg -i alacritty.deb && \
rm alacritty.deb
# Install the latest alacritty config on the host
wget -q -O $HOST_HOME/.config/alacritty/alacritty.yml https://raw.githubusercontent.com/sabrehagen/dotfiles-alacritty/master/.config/alacritty/alacritty.yml
# Take ownership of all files under the user's directory
chown $HOST_USER:$HOST_USER /$HOST_USER
# Install dotfiles configuration for host user
su $HOST_USER
vcsh clone https://github.com/sabrehagen/dotfiles-alacritty.git
vcsh clone https://github.com/sabrehagen/dotfiles-scripts.git

View file

@ -2,6 +2,7 @@
CONTAINER_USER=jackson
JACKSON_CONFIG_CHROME=/$CONTAINER_USER/home/.config/google-chrome
JACKSON_CONFIG_CODE=/$CONTAINER_USER/home/.config/Code
JACKSON_CONFIG_GITHUB=/$CONTAINER_USER/home/.config/hub
# Give the container user ownership of the JACKSON_CONFIG_CHROME volume
docker run \
@ -18,3 +19,11 @@ docker run \
--volume JACKSON_CONFIG_CODE:$JACKSON_CONFIG_CODE \
sabrehagen/desktop-environment:latest \
chown -R $CONTAINER_USER:$CONTAINER_USER $JACKSON_CONFIG_CODE
# Give the container user ownership of the JACKSON_CONFIG_GITHUB volume
docker run \
--rm \
--user root \
--volume JACKSON_CONFIG_GITHUB:$JACKSON_CONFIG_GITHUB \
sabrehagen/desktop-environment:latest \
chown -R $CONTAINER_USER:$CONTAINER_USER $JACKSON_CONFIG_GITHUB

View file

@ -6,3 +6,4 @@ sh $REPO_ROOT/scripts/clean.sh
# Remove volumes that can be recreated from scratch, but require manual configuration in app
docker volume rm JACKSON_CONFIG_CODE
docker volume rm JACKSON_CONFIG_CHROME
docker volume rm JACKSON_CONFIG_GITHUB

View file

@ -15,6 +15,7 @@ docker run \
--env SSH_AUTH_SOCK=$JACKSON_HOME/.ssh/auth.sock \
--env STEMN_GIT_EMAIL="$(git config --get user.email)" \
--env STEMN_GIT_NAME="$(git config --get user.name)" \
--env STEMN_TMUX_SESSION=desktop-session \
--group-add audio \
--group-add video \
--interactive \
@ -24,6 +25,7 @@ docker run \
--security-opt seccomp:$REPO_ROOT/config/chrome/chrome.json \
--tty \
--volume /dev/shm:/dev/shm \
--volume /etc/hosts:/etc/hosts \
--volume /etc/localtime:/etc/localtime:ro \
--volume /tmp/.X11-unix:/tmp/.X11-unix \
--volume /var/run/docker.sock:/var/run/docker.sock \