Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
ss-o committed Oct 27, 2023
1 parent 6311417 commit e6c0515
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .trunk/configs/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Following source doesn't work in most setups
ignored:
- SC1090
- SC1091
- DL3018
- SC1071
6 changes: 3 additions & 3 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ plugins:
uri: https://github.com/trunk-io/plugins
lint:
disabled:
- terrascan
- trivy
- checkov
- yamllint
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
Expand Down
26 changes: 15 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,39 @@ FROM alpine:${VERSION}
LABEL maintainer="<%= Z-Shell Community %>"
LABEL email="<%= [email protected] =%>"

ARG HOSTNAME=zi@docker
ARG ZUSER=z-user
ARG SHELL=/bin/zsh
ARG HOSTNAME=zi@docker-alpine
ARG DIR=/static
ARG SHELL=/bin/zsh
ARG ZUSER=user
ARG PUID=${UID:-1000}
ARG PGID=${GID:-1000}
ARG TERM=${TERM:-xterm-256color}

ENV ZUSER=${ZUSER}
ENV PUID=${PUID}
ENV PGID=${PGID}
ENV DIR=${DIR}
ENV TERM=${TERM}
ENV HOSTNAME=${HOSTNAME}
ENV APK_ADD=${APK_ADD}
ENV DIR=${DIR} TERM=${TERM}
ENV ZI_ZSH_VERSION=${ZI_ZSH_VERSION}
ENV ZI_HOME_DIR=${ZI_HOME_DIR} ZI_BIN_DIR=${ZI_BIN_DIR}

# trunk-ignore(hadolint/DL3018)
RUN apk --no-cache --virtual base add coreutils curl \
jq git libuser rsync sudo zsh ncurses-dev pcre-dev zlib-dev alpine-zsh-config \
jq git libuser rsync zsh ncurses-dev pcre-dev zlib-dev alpine-zsh-config \
&& apk --no-cache --virtual zsh-build-tools add autoconf bash build-base go vim

WORKDIR $DIR
WORKDIR ${DIR}
COPY . .
RUN chmod +x entrypoint.sh && ./entrypoint.sh

VOLUME ["/src", "/data"]
COPY --chown=${ZUSER} . /src
COPY --chmod=+x . /src

USER ${ZUSER}
WORKDIR /home/${ZUSER}
SHELL ["/bin/zsh", "-c"]

RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/z-shell/zi-src/main/lib/sh/install.sh)" -- -i skip
RUN curl -fsSLO 'https://raw.githubusercontent.com/z-shell/zi-src/main/lib/sh/install.sh' \
&& chmod +x install.sh && ./install.sh -i skip

CMD ["/bin/zsh", "-l"]
CMD ["zsh", "-l"]
7 changes: 2 additions & 5 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
#
# -*- mode: bash; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=bash sw=2 ts=2 et
#

col_error=""
col_info=""
Expand Down Expand Up @@ -35,11 +37,6 @@ build() {
[[ -n ${NO_CACHE} ]] && args+=(--no-cache "$@")

if docker build \
--build-arg "ZUSER=${USER:-$(id -u -n || true)}" \
--build-arg "PUID=${UID:-$(id -u || true)}" \
--build-arg "PGID=${GID:-$(id -g || true)}" \
--build-arg "TERM=${TERM:-xterm-256color}" \
--build-arg "HOSTNAME=zi@docker" \
--build-arg "ZI_ZSH_VERSION=${zsh_version}" \
--file "${dockerfile}" \
--tag "${image_name}:${tag}" \
Expand Down
14 changes: 9 additions & 5 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
#
# -*- mode: bash; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=bash sw=2 ts=2 et
#

col_error=""
col_info=""
Expand Down Expand Up @@ -153,14 +155,17 @@ if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then
CONTAINER_IMAGE="$2"
shift 2
;;
# Set the tag of the container image
-t | --tag)
CONTAINER_TAG="$2"
shift 2
;;
# Set an environment variable in the container
-e | --env | --environment)
CONTAINER_ENV+=("$2")
shift 2
;;
# Mount a volume into the container
-v | --volume)
CONTAINER_VOLUMES+=("$2")
shift 2
Expand All @@ -170,6 +175,7 @@ if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then
WRAP_CMD=1
shift
;;
# Whether to run zd with zunit
--tests | --zunit | -z)
ZUNIT=1
shift
Expand Down Expand Up @@ -205,13 +211,11 @@ if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then
cd -P -- "$(dirname "$0")"
pwd -P
)" || exit 9
# Mount root of the repo to /src
# Mount /tmp/zunit-zd to /data
CONTAINER_VOLUMES+=(
"${CONTAINER_ROOT}:/src"
"${TMPDIR:-/tmp}/ZZUnit:/data"
"${ROOT_DIR}/zshenv:/home/z-user/.zshenv"
"${ROOT_DIR}/zshrc:/home/z-user/.zshrc"
"${TMPDIR:-/tmp}/runtime_data:/data"
"${ROOT_DIR}/zshenv:/home/user/.zshenv"
"${ROOT_DIR}/zshrc:/home/user/.zshrc"
)
CONTAINER_ENV+=(
"QUIET=1"
Expand Down
2 changes: 1 addition & 1 deletion docker/tests/setup.zsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env zunit

setup() {
export DATA_DIR="${TMPDIR:-/tmp}/ZZUnit"
export DATA_DIR="${TMPDIR:-/tmp}/runtime_data"
export PLUGINS_DIR="${DATA_DIR}/plugins"
export SNIPPETS_DIR="${DATA_DIR}/snippets"
export ZPFX="${DATA_DIR}/polaris"
Expand Down
2 changes: 1 addition & 1 deletion docker/utils.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ zi::setup-minimal() {
zi::pack-zsh() {
local ZSH_VERSION="$1"
zi pack"$ZSH_VERSION" for zsh
zi pack atload=+"zicompinit; zicdreplay" for system-completions
zi pack atload=+"zicompinit; zicdreplay" for system-completions
}
2 changes: 1 addition & 1 deletion docker/zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export TERM=${TERM:-xterm-256color}
export SHELL=${SHELL:-${commands[zsh]}}

typeset -Ag ZI

export ZI[HOME_DIR]=${ZI_HOME_DIR:-/data}
export ZI[BIN_DIR]=${ZI_BIN_DIR:-$HOME/.zi/bin}

0 comments on commit e6c0515

Please sign in to comment.