diff options
| -rwxr-xr-x | dev.sh | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +GIT_CONFIG=${GIT_CONFIG_SYSTEM:-$HOME/.gitconfig} + +OCI_RUNTIME=podman + +DEV_DOCKERFILE=Dockerfile.dev +DEV_IMAGE=equity-tracker:develop +CONTAINER_SHELL=zsh +CONTAINER_USER=sparrow +CONTAINER_WORKDIR=/code +CONTAINER_GPG=/home/$CONTAINER_USER/.gnupg +CONTAINER_SSH=$CONTAINER_GPG/S.gpg-agent.ssh + +NS_UID=$(id -u) +NS_GID=$(id -g) + +GPG_SOCK_DIR=/run/user/$NS_UID/gnupg + +if ! git diff-index --quiet HEAD -- $DEV_DOCKERFILE \ +|| ! $OCI_RUNTIME image exists $DEV_IMAGE; +then + $OCI_RUNTIME build -f $DEV_DOCKERFILE \ + -t $DEV_IMAGE \ + . +fi + +$OCI_RUNTIME run -it \ + --rm \ + --mount type=bind,source=.,target=$CONTAINER_WORKDIR \ + --mount type=bind,source=$HOME/.config/helix,target=/home/$CONTAINER_USER/.config/helix,ro \ + --mount type=bind,source=$GIT_CONFIG,target=/home/$CONTAINER_USER/.gitconfig,ro \ + --mount type=bind,source=$GPG_SOCK_DIR/S.gpg-agent,target=$CONTAINER_GPG/S.gpg-agent \ + --mount type=bind,source=$GPG_SOCK_DIR/S.gpg-agent.extra,target=$CONTAINER_GPG/S.gpg-agent.extra \ + --mount type=bind,source=$GPG_SOCK_DIR/S.gpg-agent.ssh,target=$CONTAINER_SSH \ + -w $CONTAINER_WORKDIR \ + --userns=keep-id:uid=$NS_UID,gid=$NS_GID \ + --env SSH_AUTH_SOCK=$CONTAINER_SSH \ + $DEV_IMAGE \ + $CONTAINER_SHELL +exit |
