1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/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=$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 \
--env SSH_AUTH_SOCK=$CONTAINER_SSH \
$DEV_IMAGE \
$CONTAINER_SHELL
exit
|