Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐳 Add annexes to container #103

Merged
merged 3 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ ENV PUSERNAME=${PUSERNAME} PUID=${PUID} PGID=${PGID} \
TERM=${TERM} ZINIT_ZSH_VERSION=${ZINIT_ZSH_VERSION}

RUN apk --no-cache --virtual base add \
zsh curl git libuser sudo && \
zsh curl git libuser sudo rsync && \
apk --no-cache --virtual build-tools add \
build-base autoconf ncurses-dev bash go

RUN sed -ir 's#^(root:.+):/bin/ash#\1:/bin/zsh#' /etc/passwd && \
adduser -D -s /bin/zsh -u "${PUID}" -h "/home/${PUSERNAME}" \
"${PUSERNAME}" && \
printf "${PUSERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/user && \
mkdir -p /src /data && \
chown -R "${PUID}:${PGID}" /data && \
mkdir -p /src /data /data-static && \
chown -R "${PUID}:${PGID}" /data /data-static && \
ln -sfv /src/docker/zshenv /home/${PUSERNAME}/.zshenv && \
ln -sfv /src/docker/zshrc /home/${PUSERNAME}/.zshrc

Expand All @@ -33,8 +33,7 @@ USER ${PUSERNAME}

# Fetch keys config and store it outside of ZINIT[HOME_DIR] since it might get
# overridden at runtime (the /data volume)
RUN zsh -ils -c -- '@zinit-scheduler burst' && \
cp -vf /data/snippets/OMZL::key-bindings.zsh/OMZL::key-bindings.zsh \
/home/${PUSERNAME}/OMZL::key-bindings.zsh
RUN ZINIT_HOME_DIR=/data-static ZSH_NO_INIT=1 \
zsh -ils -c -- '@zinit-scheduler burst'

CMD ["/bin/zsh"]
18 changes: 18 additions & 0 deletions docker/init.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Fix permissions on /data
if [[ -z "$QUIET" ]]
then
echo "Setting owner of /data to ${PUID}:${PGID}" >&2
fi

sudo chown "${PUID}:${PGID}" /data
sudo chown -R "${PUID}:${PGID}" /data

# sync files between /data-static and /data
if [[ -z "$NOTHING_FANCY" ]]
then
if [[ -z "$QUIET" ]]
then
echo "Copying files from /data-static to /data" >&2
fi
rsync -raq /data-static/ /data
fi
9 changes: 1 addition & 8 deletions docker/utils.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ zinit::setup() {
}

zinit::setup-keys() {
local file="${HOME}/OMZL::key-bindings.zsh"

if [[ -r "$file" ]]
then
source "$file"
else
zinit snippet OMZL::key-bindings.zsh
fi
zinit snippet OMZL::key-bindings.zsh
}

zinit::setup-annexes() {
Expand Down
4 changes: 3 additions & 1 deletion docker/zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
export TERM=${TERM:-xterm-256color}
typeset -Ag ZINIT

export ZINIT[HOME_DIR]=/data
# ZINIT_HOME_DIR is used at build time to force the installation of plugins
# etc to /data-static
export ZINIT[HOME_DIR]=${ZINIT_HOME_DIR:-/data}
export ZINIT[BIN_DIR]=/src
18 changes: 9 additions & 9 deletions docker/zshrc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Fix permissions on /data (run only once, at startup)
if [[ "$$" == 1 ]]
# Initialization. Trigger stuff that only needs to be run once, at startup.
if [[ "$$" == 1 ]] && [[ -z "$ZSH_NO_INIT" ]]
then
if [[ -z "$QUIET" ]]
then
echo "Setting owner of /data to ${PUID}:${PGID}" >&2
fi
sudo chown /data
sudo chown -R "${PUID}:${PGID}" /data
source /src/docker/init.zsh
fi

# load zinit
source /src/zinit.zsh
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

# load zinit setup utility functions
source /src/docker/utils.zsh

# Annexes
[[ -z "$NOTHING_FANCY" ]] && zinit::setup-annexes

# Add ZPFX/bin to PATH
typeset -U path
path=("${ZPFX:-${HOME}/.local/share/zinit/polaris}/bin" $path)
Expand All @@ -33,6 +33,6 @@ then
fi

# Setup keys
zinit::setup-keys
[[ -z "$NOTHING_FANCY" ]] && zinit::setup-keys

# vim: ft=zsh et ts=2 sw=2 :
1 change: 1 addition & 0 deletions scripts/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ then
)
CONTAINER_ENV+=(
"QUIET=1"
"NOTHING_FANCY=1"
)
fi

Expand Down