Skip to content

Manala up - introduce zsh #717

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion .manala.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ manala:

project:
name: manala-ansible-roles
help: |
## Containerd ##
Build of test containers with Molecule is incompatible with Containerd on Mac ARM
Turn it off in Docker Desktop in order to launch your tests in local

##########
# System #
Expand Down Expand Up @@ -41,6 +45,6 @@ system:
ansible-lint:
version: 24.7.0
molecule:
version: 24.7.0
version: 24.12.0
dependencies:
- molecule-plugins[docker]==23.5.3
2 changes: 1 addition & 1 deletion .manala/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sh:
else \
$(call manala_docker_command, \
$(if $(PORT),--publish $(PORT)), \
) bash --login ; \
) zsh --login ; \
fi
.PHONY: sh

Expand Down
41 changes: 26 additions & 15 deletions .manala/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ ARG MANALA_USER_ID="1000"
ARG MANALA_GROUP_ID="1000"

ARG GOSU_VERSION="1.17"
ARG GOMPLATE_VERSION="4.1.0"
ARG DIRENV_VERSION="2.34.0"
ARG GOMPLATE_VERSION="4.2.0"
ARG DIRENV_VERSION="2.35.0"
ARG JQ_VERSION="1.7.1"
ARG YQ_VERSION="4.44.3"
ARG YQ_VERSION="4.44.5"
ARG STARSHIP_VERSION="1.21.1"
ARG FZF_VERSION="0.56.3"

# The 'container' environment variable tells systemd that it's running inside a
# Docker container environment.
Expand All @@ -23,13 +25,15 @@ ENV container="docker"
# Default locale
ENV LANG="C.UTF-8"

# Starship
ENV STARSHIP_CONFIG=/etc/starship/starship.toml

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN \
apt-get --quiet update \
&& apt-get --quiet --yes --purge --autoremove upgrade \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
bash-completion \
bzip2 \
ca-certificates \
curl \
Expand All @@ -43,9 +47,10 @@ RUN \
socat \
sudo \
vim \
zsh \
# User
&& addgroup --gid ${MANALA_GROUP_ID} lazy \
&& adduser --home /home/lazy --shell /bin/bash --uid ${MANALA_USER_ID} --gecos lazy --ingroup lazy --disabled-password lazy \
&& adduser --home /home/lazy --shell /bin/zsh --uid ${MANALA_USER_ID} --gecos lazy --ingroup lazy --disabled-password lazy \
&& install --verbose --mode 0755 --group lazy --owner lazy --directory /run/user/${MANALA_USER_ID} \
&& echo "lazy ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/lazy \
# Gosu
Expand All @@ -68,10 +73,20 @@ RUN \
&& curl -sSLf "https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \
--output /usr/local/bin/yq \
&& chmod +x /usr/local/bin/yq \
# Bash completion
&& install --verbose --mode 0755 --directory /etc/bash_completion.d \
# Oh My Bash
&& git clone https://github.com/ohmybash/oh-my-bash.git /usr/local/share/oh-my-bash \
# Oh My Zsh
&& git clone https://github.com/ohmyzsh/ohmyzsh.git /usr/local/share/oh-my-zsh \
# See: https://github.com/ohmyzsh/ohmyzsh/issues/11995
&& git clone https://github.com/zsh-users/zsh-autosuggestions.git /usr/local/share/oh-my-zsh/custom/plugins/zsh-autosuggestions \
&& git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /usr/local/share/oh-my-zsh/custom/plugins/zsh-syntax-highlighting \
&& echo "ZDOTDIR=/etc/zsh" > /etc/zsh/zshenv \
# Starship
&& curl -sSLf "https://github.com/starship/starship/releases/download/v${STARSHIP_VERSION}/starship-$(case $(dpkg --print-architecture) in "amd64") echo "x86_64" ;; "arm64") echo "aarch64" ;; esac)-unknown-linux-musl.tar.gz" \
| bsdtar -xvf - -C /usr/local/bin \
&& echo "Defaults env_keep += STARSHIP_CONFIG" > /etc/sudoers.d/starship \
# Fzf
&& curl -sSLf "https://github.com/junegunn/fzf/releases/download/v${FZF_VERSION}/fzf-${FZF_VERSION}-linux_$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac).tar.gz" \
| bsdtar -xvf - -C /usr/local/bin \
&& chmod +x /usr/local/bin/fzf \
# Clean
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -88,13 +103,10 @@ RUN \
openssh-client \
pipx \
python3 \
python3-argcomplete \
shellcheck \
sshpass \
# Sudo
&& echo "Defaults env_keep += \"PIPX_*\"" > /etc/sudoers.d/pipx \
# Bash completion
&& activate-global-python-argcomplete --dest /etc/bash_completion.d \
# Clean
&& rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -140,12 +152,11 @@ RUN \
# Molecule
RUN \
pipx install --pip-args="--no-cache-dir" \
molecule==24.7.0 \
&& _MOLECULE_COMPLETE=bash_source molecule > /etc/bash_completion.d/molecule \
molecule==24.12.0 \
&& pipx inject --pip-args="--no-cache-dir" molecule \
molecule-plugins[docker]==23.5.3

# Run
COPY docker/entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
CMD ["zsh"]
11 changes: 8 additions & 3 deletions .manala/docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ services:
build:
context: ..
dockerfile: docker/Dockerfile
image: manala-ansible-roles:20240916111724
image: manala-ansible-roles:20241217124745
pull_policy: never
volumes:
- ../..:${MANALA_DIR}
environment:
Expand All @@ -22,5 +23,9 @@ services:
- path: ../../.env.local
required: false
working_dir: ${MANALA_DIR}
# Use default docker bridge network
network_mode: bridge
networks:
- network

networks:
network:
name: manala-ansible-roles
9 changes: 9 additions & 0 deletions .manala/docker/compose/term.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:

##########
# System #
##########

system:
environment:
TERM: ${TERM:-xterm}
3 changes: 3 additions & 0 deletions .manala/docker/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ MANALA_DOCKER_COMPOSE_FILE += \
# Debug
MANALA_DOCKER_COMPOSE_ENV += $(if $(MANALA_DOCKER_DEBUG), BUILDKIT_PROGRESS=plain)

# Term
MANALA_DOCKER_COMPOSE_FILE += $(MANALA_DIR)/.manala/docker/compose/term.yaml

# Usage:
# $(manala_docker_compose) [COMMAND] [ARGS...]

Expand Down
6 changes: 4 additions & 2 deletions .manala/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@ set -e
# Ssh agent bridge
if [ -n "${SSH_AUTH_SOCK}" ]; then
sh -c " \
while sleep 1; do \
while true; do \
rm -f /var/run/ssh-auth-bridge.sock ;
socat \
UNIX-LISTEN:/var/run/ssh-auth-bridge.sock,fork,mode=777 \
UNIX-CONNECT:/var/run/ssh-auth.sock ; \
sleep 1; \
done \
" &
fi

# Docker bridge
if [ -n "${DOCKER_HOST}" ]; then
sh -c " \
while sleep 1; do \
while true; do \
rm -f /var/run/docker-bridge.sock ;
socat -t 600 \
UNIX-LISTEN:/var/run/docker-bridge.sock,fork,mode=777 \
UNIX-CONNECT:/var/run/docker.sock ; \
sleep 1; \
done \
" &
fi
Expand Down
148 changes: 0 additions & 148 deletions .manala/etc/profile.d/oh-my-bash.sh

This file was deleted.

24 changes: 24 additions & 0 deletions .manala/etc/starship/starship.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Starship config template
# Don't edit this file directly. Instead, set config in project .manala.yaml, and run `manala up`.

format = """
[╭─](cyan)$username$hostname$directory$direnv$env_var$custom
[╰](cyan) $cmd_duration$character"""

[username]
show_always = true
format = '[$user]($style)@'
style_user = 'yellow'

[hostname]
ssh_only = false
style = 'yellow'

[directory]
truncation_length = 1
truncation_symbol = '…/'
read_only = ''
style = 'cyan'

[direnv]
disabled = false
8 changes: 7 additions & 1 deletion .manala/etc/profile.d/message.sh → .manala/etc/zsh/.zlogin
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ printf "\n"
printf " \033[36m‣ ansible \033[35m2.15.12\033[0m\n"
printf " \033[36m· docker==7.1.0\033[0m\n"
printf " \033[36m‣ ansible-lint \033[35m24.7.0\033[0m\n"
printf " \033[36m‣ molecule \033[35m24.7.0\033[0m\n"
printf " \033[36m‣ molecule \033[35m24.12.0\033[0m\n"
printf " \033[36m· molecule-plugins[docker]==23.5.3\033[0m\n"
printf "\n"
cat << EOF
## Containerd ##
Build of test containers with Molecule is incompatible with Containerd on Mac ARM
Turn it off in Docker Desktop in order to launch your tests in local
EOF
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
eval "$(direnv hook bash)"
##########
# Direnv #
##########

# Config directory
export DIRENV_CONFIG=/etc/direnv
Expand Down
Loading
Loading