#!/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/equity-tracker 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 --build-arg WORKING_DIR=$CONTAINER_WORKDIR \ -f $DEV_DOCKERFILE \ -t $DEV_IMAGE \ . fi $OCI_RUNTIME run -it \ --rm \ --mount type=bind,source=.,target=$CONTAINER_WORKDIR \ --mount type=bind,source=$HOME/.cargo/registry,target=/usr/local/cargo/registry \ --mount type=bind,source=$HOME/.config/helix,target=/home/$CONTAINER_USER/.config/helix \ --mount type=bind,source=$HOME/.ssh/config,target=/home/$CONTAINER_USER/.ssh/config,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 \ --security-opt=seccomp=unconfined \ --env SSH_AUTH_SOCK=$CONTAINER_SSH \ $DEV_IMAGE \ $CONTAINER_SHELL exit