Compare commits

...

39 Commits

Author SHA1 Message Date
f8c5a5071d feat(infar): add just
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 1m37s
Build containers / dependent-images (go) (push) Successful in 21s
Build containers / dependent-images (infra) (push) Successful in 54s
Build containers / dependent-images (php) (push) Successful in 1m0s
2026-03-29 15:33:26 +02:00
12a9bec916 fix: PS1 and faster fzf
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 1m3s
Build containers / dependent-images (go) (push) Successful in 21s
Build containers / dependent-images (php) (push) Successful in 47s
Build containers / dependent-images (infra) (push) Successful in 42s
2026-03-22 11:05:39 +01:00
ccd1cafa80 fix: php container
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 1m25s
Build containers / dependent-images (go) (push) Successful in 24s
Build containers / dependent-images (infra) (push) Successful in 1m2s
Build containers / dependent-images (php) (push) Successful in 48s
2026-03-19 21:15:30 +01:00
06491c1a02 ci: remove squash
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 37s
Build containers / dependent-images (go) (push) Successful in 23s
Build containers / dependent-images (php) (push) Successful in 20s
Build containers / dependent-images (infra) (push) Successful in 51s
2026-03-19 21:03:52 +01:00
54534cceab feat: add rg
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 43s
Build containers / dependent-images (go) (push) Successful in 22s
Build containers / dependent-images (php) (push) Successful in 45s
Build containers / dependent-images (infra) (push) Successful in 50s
2026-03-19 20:58:10 +01:00
b44b0c248c ci: squash base container
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 36s
Build containers / dependent-images (go) (push) Successful in 23s
Build containers / dependent-images (php) (push) Successful in 20s
Build containers / dependent-images (infra) (push) Successful in 49s
2026-03-19 20:46:12 +01:00
bc86a1d58c fix: go toolchain
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Has been skipped
Build containers / dependent-images (infra) (push) Successful in 1s
Build containers / dependent-images (php) (push) Successful in 2s
Build containers / dependent-images (go) (push) Successful in 21s
2026-03-19 20:45:13 +01:00
614168c903 fix: remove npm from base container
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 36s
Build containers / dependent-images (go) (push) Successful in 9s
Build containers / dependent-images (php) (push) Successful in 17s
Build containers / dependent-images (infra) (push) Successful in 47s
2026-03-19 20:39:15 +01:00
183ccc0072 fix: remove go from base container
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 42s
Build containers / dependent-images (go) (push) Successful in 9s
Build containers / dependent-images (php) (push) Successful in 20s
Build containers / dependent-images (infra) (push) Successful in 45s
2026-03-19 20:35:38 +01:00
8b31b61380 feat: use go from go.dev and switch to zig as c compiler
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 45s
Build containers / dependent-images (go) (push) Successful in 17s
Build containers / dependent-images (php) (push) Successful in 20s
Build containers / dependent-images (infra) (push) Successful in 54s
2026-03-19 20:33:21 +01:00
5f87d970f9 refactor: remove git perl dependencies
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 45s
Build containers / dependent-images (go) (push) Successful in 19s
Build containers / dependent-images (php) (push) Successful in 22s
Build containers / dependent-images (infra) (push) Successful in 49s
2026-03-19 20:13:03 +01:00
f96fd2eff5 refactor: move nvim to github download
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 45s
Build containers / dependent-images (go) (push) Successful in 17s
Build containers / dependent-images (php) (push) Successful in 19s
Build containers / dependent-images (infra) (push) Successful in 56s
2026-03-19 20:09:48 +01:00
3d4c258bb1 refactor: use github for lazysql and lazydocker
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 2m22s
Build containers / dependent-images (go) (push) Successful in 17s
Build containers / dependent-images (php) (push) Successful in 20s
Build containers / dependent-images (infra) (push) Successful in 56s
2026-03-19 19:57:32 +01:00
9cd843f749 feat: add dnf cache
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 1m16s
Build containers / dependent-images (go) (push) Successful in 21s
Build containers / dependent-images (php) (push) Successful in 18s
Build containers / dependent-images (infra) (push) Successful in 1m0s
2026-03-19 19:49:17 +01:00
18889e3d26 feat: add fd-find 2026-03-19 19:44:13 +01:00
b3215c96f3 refactor: shrink container build
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 44s
Build containers / dependent-images (go) (push) Successful in 17s
Build containers / dependent-images (php) (push) Successful in 23s
Build containers / dependent-images (infra) (push) Successful in 50s
2026-03-17 21:23:54 +01:00
056ff220c5 ci: fix dependent images check 2026-03-17 20:37:39 +01:00
f67738b5ec refactor: simplify container build
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 1m39s
Build containers / dependent-images (go) (push) Successful in 2s
Build containers / dependent-images (infra) (push) Successful in 2s
Build containers / dependent-images (php) (push) Successful in 2s
2026-03-17 20:32:21 +01:00
2ca42d5add refactor: simplify log, die and formatting
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 2m41s
Build containers / dependent-images (go) (push) Successful in 4s
Build containers / dependent-images (infra) (push) Successful in 2s
Build containers / dependent-images (php) (push) Successful in 2s
2026-03-17 20:26:33 +01:00
f895c11cbd feat: add bash vi mode 2026-03-17 20:25:51 +01:00
5ce5004482 fix: dev containers without config file 2026-03-15 21:29:07 +01:00
e643f9974a chore: fix formatting 2026-03-15 16:02:03 +01:00
d74f42b7fa refactor: use build in bash functions to get script path 2026-03-15 15:59:02 +01:00
75e1d916d2 refactor: simplify devc script
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 2m8s
Build containers / dependent-images (go) (push) Successful in 2s
Build containers / dependent-images (infra) (push) Successful in 2s
Build containers / dependent-images (php) (push) Successful in 2s
2026-03-15 15:54:31 +01:00
363355bfe0 fix: do not export PS1 2026-03-15 15:54:18 +01:00
9edab5b046 fix: permissions of host script 2026-03-15 15:54:07 +01:00
b07ae7ea7f refactor: simplify host script 2026-03-15 15:53:47 +01:00
955b5030e6 refactor: simplify pipeline 2026-03-15 15:53:38 +01:00
0089c971f4 refactor: small optimalizations 2026-03-15 12:37:34 +01:00
16841bb334 refactor: rename fedora to base 2026-03-15 11:10:02 +01:00
a1f7a46a73 feat: add devc network 2026-03-15 11:08:33 +01:00
d8367d41cd feat: install nvim nightly
All checks were successful
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 2m3s
Build containers / dependent-images (go) (push) Successful in 23s
Build containers / dependent-images (infra) (push) Successful in 48s
Build containers / dependent-images (php) (push) Successful in 21s
2026-03-01 14:13:20 +01:00
433846ada7 ci: remove arm build 2026-02-28 12:14:47 +01:00
67e709b65f fix: infra container
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / base-image (push) Successful in 8m40s
Build containers / dependent-images (go) (push) Successful in 1m12s
Build containers / dependent-images (php) (push) Successful in 1m25s
Build containers / dependent-images (infra) (push) Successful in 2m40s
2026-02-22 16:35:22 +01:00
6d817d31cd feat: upgrade to fedora 44
Some checks failed
Build containers / changes (push) Successful in 2s
Build containers / base-image (push) Successful in 10m34s
Build containers / dependent-images (infra) (push) Failing after 48s
Build containers / dependent-images (go) (push) Successful in 1m10s
Build containers / dependent-images (php) (push) Successful in 1m17s
2026-02-22 15:56:09 +01:00
2f0327fa55 ci: build for arm
All checks were successful
Build containers / changes (push) Successful in 3s
Build containers / dependent-images (infra) (push) Has been skipped
Build containers / base-image (push) Successful in 7m10s
Build containers / dependent-images (go) (push) Successful in 1m7s
Build containers / dependent-images (php) (push) Successful in 1m4s
2026-02-21 11:11:04 +01:00
e2b563270c refactor: make script more portable 2026-02-21 11:07:42 +01:00
2e8375d34f fix: detach keys conflicting with lazysql
Some checks failed
Build containers / changes (push) Has been cancelled
Build containers / base-image (push) Has been cancelled
Build containers / dependent-images (go) (push) Has been cancelled
Build containers / dependent-images (infra) (push) Has been cancelled
Build containers / dependent-images (php) (push) Has been cancelled
2026-02-21 10:41:36 +01:00
dc2f2991bc feat: add lazysql 2026-02-21 10:41:17 +01:00
17 changed files with 140 additions and 158 deletions

View File

@@ -14,10 +14,10 @@ jobs:
changes: changes:
runs-on: job-v2 runs-on: job-v2
outputs: outputs:
fedora: ${{ steps.filter.outputs.fedora == 'true' }} base: ${{ steps.filter.outputs.base == 'true' }}
infra: ${{ steps.filter.outputs.infra == 'true' || steps.filter.outputs.fedora == 'true' }} infra: ${{ steps.filter.outputs.infra == 'true' || steps.filter.outputs.base == 'true' }}
go: ${{ steps.filter.outputs.go == 'true' || steps.filter.outputs.fedora == 'true' }} go: ${{ steps.filter.outputs.go == 'true' || steps.filter.outputs.base == 'true' }}
php: ${{ steps.filter.outputs.php == 'true' || steps.filter.outputs.fedora == 'true' }} php: ${{ steps.filter.outputs.php == 'true' || steps.filter.outputs.base == 'true' }}
any_change: ${{ steps.filter.outputs.workflow == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}} any_change: ${{ steps.filter.outputs.workflow == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -26,14 +26,14 @@ jobs:
with: with:
filters: | filters: |
workflow: ['.gitea/workflows/build.yaml'] workflow: ['.gitea/workflows/build.yaml']
fedora: ['containers/fedora/**'] base: ['containers/base/**']
infra: ['containers/infra/**'] infra: ['containers/infra/**']
go: ['containers/go/**'] go: ['containers/go/**']
php: ['containers/php/**'] php: ['containers/php/**']
base-image: base-image:
needs: [changes] needs: [changes]
if: ${{ needs.changes.outputs.fedora == 'true' || needs.changes.outputs.any_change == 'true' }} if: ${{ needs.changes.outputs.base == 'true' || needs.changes.outputs.any_change == 'true' }}
runs-on: job-v2 runs-on: job-v2
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -47,10 +47,11 @@ jobs:
id: build id: build
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
with: with:
image: job79/fedora image: job79/base
tags: ${{ github.ref_name }} tags: ${{ github.ref_name }}
context: ./containers/fedora context: ./containers/base
containerfiles: ./containers/fedora/Containerfile containerfiles: ./containers/base/Containerfile
platforms: linux/amd64
- name: Push - name: Push
uses: redhat-actions/push-to-registry@v2 uses: redhat-actions/push-to-registry@v2
with: with:
@@ -99,6 +100,7 @@ jobs:
context: ./containers/${{ matrix.container }} context: ./containers/${{ matrix.container }}
containerfiles: ./containers/${{ matrix.container }}/Containerfile containerfiles: ./containers/${{ matrix.container }}/Containerfile
build-args: TAG=${{ github.ref_name }} build-args: TAG=${{ github.ref_name }}
platforms: linux/amd64
- name: Push - name: Push
if: steps.check.outputs.run == 'true' if: steps.check.outputs.run == 'true'
uses: redhat-actions/push-to-registry@v2 uses: redhat-actions/push-to-registry@v2

View File

@@ -0,0 +1,32 @@
FROM quay.io/fedora/fedora:44
# === install system packages ===
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf update -y && \
dnf -y --setopt=keepcache=1 --setopt=install_weak_deps=False install \
bash-completion git-core fzf curl awk jq fd-find rg unzip which \
host-spawn wl-copy gcc
RUN LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | jq -r .tag_name | sed 's/^v//') && \
curl -sL "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_linux_x86_64.tar.gz" | tar xz -C /usr/local/bin lazygit && \
curl -sL "https://github.com/jorgerojas26/lazysql/releases/latest/download/lazysql_Linux_x86_64.tar.gz" | tar xz -C /usr/local/bin lazysql && \
curl -sL "https://github.com/neovim/neovim/releases/download/nightly/nvim-linux-x86_64.tar.gz" | tar xz -C /usr/local --strip-components=1
COPY config/bin /usr/local/bin
# === setup user ===
RUN useradd -ms /bin/bash user && \
echo 'user ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/user && \
mkdir -p /run/user/1000 && \
chown user:user /run/user/1000
USER user
WORKDIR /home/user
RUN mkdir -p .config .local .cache && \
git clone https://git.plabble.org/Job79/neovim-config.git .config/nvim
COPY --chown=user:user config/bashrc .bashrc
COPY --chown=user:user config/git .config/git/config
VOLUME /home/user

View File

@@ -0,0 +1,21 @@
source /etc/bashrc
# === bash settings ===
set -o vi
bind -m vi-insert '"\C-l": clear-screen'
# === environment ===
export PS1="\[\e[30;46m\] \h | \w \[\e[0;36m\]\[\e[m\] " \
EDITOR="nvim" \
WAYLAND_DISPLAY="wayland-0" \
XDG_RUNTIME_DIR="/run/user/1000" \
SSH_AUTH_SOCK="/run/user/1000/ssh-auth-sock" \
TZ="Europe/Amsterdam" \
FZF_CTRL_T_COMMAND="fd --type f --hidden --exclude .git --exclude Library --exclude .cache" \
FZF_ALT_C_COMMAND="fd --type d --hidden --exclude .git --exclude Library --exclude .cache"
# === aliases and functions ===
alias vi=nvim
post() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
eval "$(fzf --bash)"

View File

@@ -0,0 +1,6 @@
#!/bin/bash
export DBUS_SESSION_BUS_ADDRESS="unix:path=/tmp/bus"
cmd="${0##*/}"
[[ "$cmd" == "host" ]] && unset cmd
exec host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" ${cmd:+"$cmd"} "$@"

View File

@@ -1,24 +0,0 @@
FROM quay.io/fedora/fedora:43
# === install system packages ===
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf update -y && \
dnf copr enable -y atim/lazygit && \
dnf copr enable -y atim/lazydocker && \
dnf -y --setopt=keepcache=1 install procps ping bash-completion glibc-langpack-en \
host-spawn dbus-launch \
zoxide git npm neovim awk jq unzip fd-find lazygit lazydocker
# === setup user ===
RUN useradd -ms /bin/bash user && echo 'user ALL=NOPASSWD: ALL' > /etc/sudoers && mkdir -p /run/user/1000 && chown user:user /run/user/1000
USER user
WORKDIR /home/user
RUN mkdir .config .local .cache && \
git clone https://git.plabble.org/Job79/neovim-config.git .config/nvim
COPY --chown=user:user config/bashrc .bashrc
COPY --chown=user:user config/git .config/git/config
COPY config/bin /usr/local/bin
VOLUME /home/user

View File

@@ -1,16 +0,0 @@
. /etc/bashrc
# === environment ===
export EDITOR=nvim \
WAYLAND_DISPLAY=wayland-0 \
XDG_RUNTIME_DIR=/run/user/1000 \
SSH_AUTH_SOCK=/run/user/1000/ssh-auth-sock \
PS1="\[\e[30;46m\] \h | \w \[\e[0;36m\]\[\e[m\] " \
TZ="Europe/Amsterdam"
# === aliases and functions ===
alias vi=nvim
post() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
eval "$(zoxide init --cmd cd bash)"
eval "$(fzf --bash)"

View File

@@ -1,4 +0,0 @@
#!/bin/bash
export DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/bus
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" \
$([ "$(basename "$0")" != "host" ] && echo "$(basename "$0")") "$@"

View File

@@ -1,8 +1,10 @@
ARG TAG ARG TAG
FROM job79/fedora:${TAG} FROM job79/base:${TAG}
USER root USER root
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \ RUN GO_VERSION=$(curl -sL "https://go.dev/VERSION?m=text" | head -n 1 | tr -d '\r\n') && \
dnf -y --setopt=keepcache=1 install go curl -sL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" | tar xz -C /usr/local && \
ln -sf /usr/local/go/bin/go /usr/local/bin/go && \
ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt
USER user USER user

View File

@@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
arg "-v $HOME/Documents/go:/home/user/Documents/go" run_opts+=("-v" "$HOME/Documents/go:/home/user/Documents/go")

View File

@@ -1,9 +1,10 @@
ARG TAG ARG TAG
FROM job79/fedora:${TAG} FROM job79/base:${TAG}
USER root USER root
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \ RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y --setopt=keepcache=1 install kubectl k9s openssl age "$(curl -s https://api.github.com/repos/getsops/sops/releases/latest | jq -r '.assets[] | select(.name | test("sops-.*.x86_64.rpm$")) | .browser_download_url')" && \ dnf -y --setopt=keepcache=1 --setopt=install_weak_deps=False install \
just kubectl k9s openssl age "$(curl -s https://api.github.com/repos/getsops/sops/releases/latest | jq -r ".assets[] | select(.name | test(\"sops-.*.$(arch).rpm\$\")) | .browser_download_url")" && \
curl -sL https://talos.dev/install | sh && \ curl -sL https://talos.dev/install | sh && \
curl -s https://fluxcd.io/install.sh | bash curl -s https://fluxcd.io/install.sh | bash

View File

@@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
arg "-v $HOME/Documents/infra:/home/user/Documents/infra" run_opts+=("-v" "$HOME/Documents/infra:/home/user/Documents/infra")

View File

@@ -1,9 +1,9 @@
ARG TAG ARG TAG
FROM job79/fedora:${TAG} FROM job79/base:${TAG}
USER root USER root
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \ RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y --setopt=keepcache=1 install php composer && \ dnf -y --setopt=keepcache=1 install php composer npm && \
composer global require laravel/installer composer global require laravel/installer
USER user USER user

View File

@@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
arg "-v $HOME/Documents/php:/home/user/Documents/php" run_opts+=("-v" "$HOME/Documents/php:/home/user/Documents/php")

150
devc.sh
View File

@@ -1,116 +1,78 @@
#!/bin/bash #!/bin/bash
# =============================================== # # =============================================== #
# devc.sh v2.0; job79 # # devc.sh v2.1; job79, maurice #
# Dev container enter script. Handles setting up # # Dev container entry script. #
# different dev containers, resuming sessions and #
# automatic container updates. #
# =============================================== # # =============================================== #
set -eu set -euo pipefail
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-}" "$1"; } log() { echo -e "\e[36m○\e[0m $1"; }
arg() { echo -n " $@"; } die() { echo -e "\e[31mx\e[0m $1" && exit 1; }
# run_args returns the podman run arguments required for # default_args configures standard container options.
# starting a new container.
default_args() { default_args() {
arg "--name $name" run_opts+=(
arg "--hostname $name" "--name" "$name"
"--hostname" "$name"
"--pull=newer" # Update image.
"--userns=keep-id" # Map host user.
"-v" "$name:/home/user:copy" # Persistent home volume.
"-v" "dnf-cache:/var/cache/libdnf5" # Cache dnf metadata.
)
# Pull newer container image if available. # Unix sockets require SELinux label disable.
arg "--pull=newer" [[ -d /sys/fs/selinux ]] && run_opts+=("--security-opt" "label=disable")
# Use keep-id so the container user matches the host user. # Desktop integration (Wayland, SSH).
arg "--userns=keep-id" [[ -e "/run/user/$UID/wayland-0" ]] && run_opts+=("-v" "/run/user/$UID/wayland-0:/run/user/1000/wayland-0")
[[ -e "${SSH_AUTH_SOCK:-}" ]] && run_opts+=("-v" "$SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock")
# Disable selinux labeling so unix sockets can be mounted # Load custom container config.
# without problems. local config_file="${BASH_SOURCE[0]%/*}/containers/$name/config.sh"
arg "--security-opt label=disable" [[ -f "$config_file" ]] && source "$config_file" || true
# Mount the wayland socket. Required to get the system
# clipboard (wl-copy) and gui applications working.
[ -e "/run/user/$UID/wayland-0" ] && arg "-v /run/user/$UID/wayland-0:/run/user/1000/wayland-0"
# Mount the ssh socket to get ssh working.
[ -e "$SSH_AUTH_SOCK" ] && arg "-v $SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock"
# Make the user home dir a volume so it survives container
# restarts. Use copy to keep the files from the image.
arg "-v $name:/home/user:copy"
# If there is custom configuration for the container, load
# it here.
config_file="$(dirname "$(realpath "$0")")/containers/$name/config.sh"
[ -f "$config_file" ] && source "${config_file}"
} }
# param_args returns the podman run arguments based on the # param_args parses CLI arguments into podman run options.
# arguments provided to this script.
param_args() { param_args() {
while test $# -gt 0; do while (($# > 0)); do
case "$1" in case "$1" in
-gpu) # Enable gpu acceleration. -gpu) run_opts+=("--device" "/dev/dri") ;;
arg "--device /dev/dri" ;; -host-spawn) run_opts+=("-v" "/run/user/$UID/bus:/tmp/bus" "-e" "HOST_HOME=$HOME") ;;
-host-spawn) # Enable spawning host commands from inside the container using host-spawn. -container-sock) run_opts+=("-v" "$XDG_RUNTIME_DIR/podman/podman.sock:/var/run/docker.sock") ;;
arg "-v /run/user/$UID/bus:/tmp/bus" -x11) run_opts+=("-v" "/tmp/.X11-unix:/tmp/.X11-unix" "-v" "$XAUTHORITY:/run/user/1000/.Xauthority:ro" "-e" "DISPLAY=$DISPLAY" "-e" "XAUTHORITY=/run/user/1000/.Xauthority") ;;
arg "-e HOST_HOME=$HOME" # Used to translate paths. -mnt) shift && run_opts+=("-w" "/mnt/" "-v" "$1:/mnt/$([[ -d "$1" ]] || echo "file")") ;;
;; *) run_opts+=("$1") ;;
-podman-sock) # Mount podman sock into the container.
arg "-v /run/user/$UID/podman/podman.sock:/var/run/docker.sock"
;;
-x11) # Enable X11 support.
arg "-v /tmp/.X11-unix:/tmp/.X11-unix"
arg "-v $XAUTHORITY:/run/user/1000/.Xauthority:ro"
arg "-e DISPLAY=$DISPLAY"
arg "-e XAUTHORITY=/run/user/1000/.Xauthority"
;;
-mnt) # Mount directory.
shift
arg "-w /mnt/"
arg "-v $1:/mnt/$([ ! -d "$1" ] && echo 'file')"
;;
*) # Use unknown arguments a podman arguments.
arg "$1" ;;
esac esac
shift shift
done done
} }
### MAIN ### main() {
# Get the devcontainer name from the first argument. If not local state_file="$HOME/.local/share/devc-previous-container"
# provided, use the last used name when possible. local image="${1:-}"
if [[ $# -gt 0 ]] && [[ ${1:-} != -* ]]; then
image="$1" # Resolve container name (CLI arg > Last used > Error).
[[ "$image" != *:* ]] && image="$image:main" if [[ $image && $image != -* ]]; then
echo "$image" >"$HOME/.local/share/devc-previous-container"
shift shift
elif [ -f "$HOME/.local/share/devc-previous-container" ]; then [[ $image != *:* ]] && image+=":main"
image=$(<"$HOME/.local/share/devc-previous-container") echo "$image" >"$state_file"
else elif [[ -f $state_file ]]; then
log "no container name specified" 'x' 31 image=$(<$state_file)
exit 1 else
fi die "no container name specified"
name="${image%:*}" fi
local name="${image%:*}"
# Get container registry from the DEVC_REGISTRY env # Start/Restart if not running or if arguments change configuration.
# variable. if [[ -z "$(podman ps -q -f name="^$name$" -f status=running)" ]] || (($# > 0)); then
if [ -n "${DEVC_REGISTRY:-}" ]; then log "starting $image..."
registry="$DEVC_REGISTRY"
else
log "registry unknown; set the DEVC_REGISTRY environment variable" 'x' 31
exit 1
fi
# Get container command from the DEVC_COMMAND env variable default_args
# if set, else use bash -l. param_args "$@"
if [ -z "${DEVC_COMMAND:-}" ]; then
DEVC_COMMAND="bash -l"
fi
# When container is not running or arguments are provided, [[ -n "${DEVC_REGISTRY:-}" ]] || die "registry unknown; set the DEVC_REGISTRY environment variable"
# recreate it. podman run --replace --stop-timeout 0 -td "${run_opts[@]}" "$DEVC_REGISTRY/$image"
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ] || [[ $# -gt 0 ]]; then fi
log "starting devcontainer..."
podman container rm -f -t 0 "$name" 1>/dev/null
podman run -td $(default_args) $(param_args $@) "$registry/$image"
fi
podman exec --detach-keys "ctrl-@" -it "$name" ${DEVC_COMMAND:-} exec podman exec --detach-keys "ctrl-@,ctrl-@" -it "$name" ${DEVC_COMMAND:-bash -l}
}
main "$@"