bootstrap

This commit is contained in:
Jackson Delahunt 2019-01-13 16:44:51 +11:00
parent d7fa9354ea
commit b0ab07cac3
6 changed files with 56 additions and 37 deletions

View file

@ -60,15 +60,15 @@ RUN wget -O rescuetime.deb -nv https://www.rescuetime.com/installers/rescuetime_
# Install operating system utilities
RUN apt install --yes \
sudo \
vcsh
# Enable password-less sudo for user
RUN echo "$USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers
RUN echo "$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# 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
@ -78,13 +78,13 @@ 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 echo "source $HOME/.zshenv.desktop" >> $HOME/.zshenv
RUN sed -i '1s;^;source $HOME/.zshenv.desktop\n\n;' $HOME/.zshenv
# Add custom binaries
COPY bin /usr/local/bin
# Remove root ownership of all files under non-root user directory
RUN chown -R $USER:$USER $HOME
RUN chown -R $USER:$USER /$USER
# Record container build information
ARG CONTAINER_BUILD_DATE
@ -98,4 +98,4 @@ USER $USER
WORKDIR $HOME
# Start the long-lived tmux session
ENTRYPOINT zsh -c "tmux -S $HOME/.tmux/tmux.sock new-session -d -s $STEMN_TMUX_SESSION && sleep infinity"
ENTRYPOINT zsh -c "tmux new-session -d -s $STEMN_TMUX_SESSION && sleep infinity"

View file

@ -1,2 +1,7 @@
# Configure tmux to always use utf8 mode and a fixed socket path
export CONTAINER_TMUX_SOCKET=$HOME/.tmux/tmux.sock
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

17
scripts/bootstrap-host.sh Executable file
View file

@ -0,0 +1,17 @@
# Host machine user configuration
HOST_HOME=$HOME
HOST_USER=$(whoami)
# Allow connections from docker containers to the host machine's X server
xhost local:docker
# Enable password-less sudo for the user on the host machine
echo "$HOST_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers
# Install alacritty
wget -q -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 machine
wget -q -O $HOST_HOME/.config/alacritty/alacritty.yml https://raw.githubusercontent.com/sabrehagen/dotfiles-alacritty/master/.config/alacritty/alacritty.yml

23
scripts/bootstrap-volumes.sh Executable file
View file

@ -0,0 +1,23 @@
# Jackson container user configuration
CONTAINER_USER=jackson
CONTAINER_HOME=/$CONTAINER_USER/home
# Jackson container volume configuration
JACKSON_CONFIG_CHROME=$CONTAINER_HOME/.config/google-chrome
JACKSON_CONFIG_CODE=$CONTAINER_HOME/.config/Code
# Give the container user ownership of the JACKSON_CONFIG_CHROME volume
docker run \
--rm \
--user root \
--volume JACKSON_CONFIG_CHROME:$JACKSON_CONFIG_CHROME \
sabrehagen/desktop-environment:latest \
chown -R $CONTAINER_USER:$CONTAINER_USER $JACKSON_CONFIG_CHROME
# Give the container user ownership of the JACKSON_CONFIG_CODE volume
docker run \
--rm \
--user root \
--volume JACKSON_CONFIG_CODE:$JACKSON_CONFIG_CODE \
sabrehagen/desktop-environment:latest \
chown -R $CONTAINER_USER:$CONTAINER_USER $JACKSON_CONFIG_CODE

View file

@ -1,34 +1,7 @@
# Host machine user configuration
HOST_HOME=$HOME
HOST_USER=$(whoami)
REPO_ROOT=$(dirname $(realpath $0))/..
# Jackson container user configuration
CONTAINER_USER=jackson
CONTAINER_HOME=/$CONTAINER_USER/home
JACKSON_CONFIG_CHROME=$CONTAINER_HOME/.config/google-chrome
JACKSON_CONFIG_CODE=$CONTAINER_HOME/.config/Code
# Bootstrap the local host
sh $REPO_ROOT/scripts/bootstrap-host.sh
# Allow connections from docker containers to the host's X server
xhost local:docker
# Enable password-less sudo for the host user
echo "$HOST_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers
# 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 the JACKSON_CONFIG_CHROME volume
docker run \
--rm \
--user root \
--volume JACKSON_CONFIG_CHROME:$JACKSON_CONFIG_CHROME \
sabrehagen/desktop-environment:latest \
chown -R $CONTAINER_USER:$CONTAINER_USER $JACKSON_CONFIG_CHROME
# Take ownership of the JACKSON_CONFIG_CODE volume
docker run \
--rm \
--user root \
--volume JACKSON_CONFIG_CODE:$JACKSON_CONFIG_CODE \
sabrehagen/desktop-environment:latest \
chown -R $CONTAINER_USER:$CONTAINER_USER $JACKSON_CONFIG_CODE
# Bootstrap the docker volumes
sh $REPO_ROOT/scripts/bootstrap-volumes.sh

View file

@ -3,4 +3,5 @@ REPO_ROOT=$(dirname $(realpath $0))/..
# Stop the running environment so there are no containers using the volumes, ignoring errors if it does not exist
sh $REPO_ROOT/scripts/stop.sh 2>/dev/null
# Remove volumes that can be recreated from scratch, directly from the container filesystem
docker volume rm JACKSON_HOME