Compare commits
30
Commits
main
..
ee6ffcd31a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee6ffcd31a | ||
|
|
4c454ed3ef | ||
|
|
4a9e54b8b3 | ||
|
|
9498c36701 | ||
|
|
8d2948dcef | ||
|
|
1bad1c00eb | ||
|
|
b6b9fc4f6b | ||
|
|
a8ee5a8ee1 | ||
|
|
ad2f27b8a8 | ||
|
|
d97a76499f | ||
|
|
80995c560f | ||
|
|
89dbfcb996 | ||
|
|
a67ea6c795 | ||
|
|
63ac1aae83 | ||
|
|
df8b7b5bfe | ||
|
|
53cfeb1a62 | ||
|
|
562b26b96a | ||
|
|
7465b394f4 | ||
|
|
2e49a4f3a3 | ||
|
|
755605b2fb | ||
|
|
5c7db03b32 | ||
|
|
8c13f219b5 | ||
|
|
6556db0ce6 | ||
|
|
0e51472973 | ||
|
|
54865b536a | ||
|
|
7a63471603 | ||
|
|
9a20313beb | ||
|
|
5e3d7ca7fb | ||
|
|
17e3a6840f | ||
|
|
c510c7f919 |
No files matched your search
@@ -1,44 +0,0 @@
|
|||||||
name: Build containers
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches: ["main"]
|
|
||||||
paths: ["containers/**", ".gitea/workflows/build.yaml"]
|
|
||||||
pull_request:
|
|
||||||
branches: ["main"]
|
|
||||||
paths: ["containers/**", ".gitea/workflows/build.yaml"]
|
|
||||||
schedule:
|
|
||||||
- cron: "0 16 * * FRI"
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: git.plabble.org
|
|
||||||
# Images in build order; later images build FROM the local base image.
|
|
||||||
IMAGES: base web
|
|
||||||
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref_name }}
|
|
||||||
PUSH: ${{ github.event_name != 'pull_request' }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: job-v2
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
for image in $IMAGES; do
|
|
||||||
pull=never; [[ $image == base ]] && pull=newer
|
|
||||||
buildah build --pull="$pull" \
|
|
||||||
--build-arg TAG="$TAG" \
|
|
||||||
-t "$REGISTRY/job79/$image:$TAG" "containers/$image"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Push
|
|
||||||
if: env.PUSH == 'true'
|
|
||||||
env:
|
|
||||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
run: |
|
|
||||||
buildah login -u "$REGISTRY_USERNAME" --password-stdin "$REGISTRY" <<<"$REGISTRY_TOKEN"
|
|
||||||
for image in $IMAGES; do
|
|
||||||
buildah push --compression-format=zstd:chunked --compression-level=12 "$REGISTRY/job79/$image:$TAG"
|
|
||||||
done
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
name: Container build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 16 * * FRI'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
container-build:
|
||||||
|
runs-on: plabble-sprinter
|
||||||
|
if: gitea.ref == 'refs/heads/main'
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up BuildX
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
endpoint: 'unix:///var/run/docker.sock'
|
||||||
|
- name: Login to Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.plabble.org
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Containerfile
|
||||||
|
push: true
|
||||||
|
tags: git.plabble.org/job79/dev:latest
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
FROM quay.io/fedora/fedora:41
|
||||||
|
|
||||||
|
# === setup system ===
|
||||||
|
RUN dnf update -y && dnf -y install neovim unzip \
|
||||||
|
bash-completion zoxide fd-find procps \
|
||||||
|
git go npm
|
||||||
|
|
||||||
|
# === setup container user ===
|
||||||
|
RUN useradd -ms /bin/bash user && usermod -aG wheel user && sed -i '/NOPASSWD/s/^#//g' /etc/sudoers
|
||||||
|
USER user
|
||||||
|
WORKDIR /home/user
|
||||||
|
COPY config/user/bashrc /home/user/.bashrc
|
||||||
|
COPY config/user/profile /home/user/.bash_profile
|
||||||
|
|
||||||
|
# === setup neovim ===
|
||||||
|
RUN git clone --depth 1 https://github.com/LazyVim/starter ~/.config/nvim
|
||||||
|
COPY --chown=user:user config/nvim/plugins /home/user/.config/nvim/lua/plugins
|
||||||
|
COPY --chown=user:user config/nvim/config/options.lua /home/user/.config/nvim/lua/config/options.lua
|
||||||
|
COPY --chown=user:user config/nvim/lazyvim.json /home/user/.config/nvim/lazyvim.json
|
||||||
|
|
||||||
|
# === setup container ===
|
||||||
|
ENV TZ="Europe/Amsterdam"
|
||||||
|
VOLUME /home/user/.local /home/user/.cache
|
||||||
|
CMD ["bash", "-l"]
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# =============================================== #
|
|
||||||
# devc.sh v2.2; job79, maurice #
|
|
||||||
# Dev container entry script. #
|
|
||||||
# =============================================== #
|
|
||||||
set -euo pipefail
|
|
||||||
log() { echo -e "\e[36m○\e[0m $1"; }
|
|
||||||
die() { echo -e "\e[31mx\e[0m $1" && exit 1; }
|
|
||||||
|
|
||||||
# default_args configures standard container options.
|
|
||||||
default_args() {
|
|
||||||
run_opts+=(
|
|
||||||
"--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.
|
|
||||||
)
|
|
||||||
|
|
||||||
# Unix sockets require SELinux label disable.
|
|
||||||
[[ -d /sys/fs/selinux ]] && run_opts+=("--security-opt" "label=disable")
|
|
||||||
|
|
||||||
# Desktop integration (Wayland, SSH).
|
|
||||||
[[ -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")
|
|
||||||
|
|
||||||
# Load custom container config.
|
|
||||||
local config_file="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/../containers/$name/config.sh"
|
|
||||||
[[ ! -f "$config_file" ]] || source "$config_file"
|
|
||||||
}
|
|
||||||
|
|
||||||
# param_args parses CLI arguments into podman run options.
|
|
||||||
param_args() {
|
|
||||||
while (($# > 0)); do
|
|
||||||
case "$1" in
|
|
||||||
-gpu) run_opts+=("--device" "/dev/dri") ;;
|
|
||||||
-no-pull) run_opts+=("--pull=never") ;;
|
|
||||||
-host-spawn) run_opts+=("-v" "/run/user/$UID/bus:/tmp/bus" "-e" "HOST_HOME=$HOME") ;;
|
|
||||||
-container-sock) run_opts+=("-v" "$XDG_RUNTIME_DIR/podman/podman.sock:/var/run/docker.sock") ;;
|
|
||||||
-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") ;;
|
|
||||||
-mnt) shift && run_opts+=("-w" "/mnt/" "-v" "$(realpath "$1"):/mnt/$([[ -d "$1" ]] || echo "file")") ;;
|
|
||||||
*) run_opts+=("$1") ;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local state_file="$HOME/.local/share/devc-previous-container"
|
|
||||||
local image="${1:-}"
|
|
||||||
|
|
||||||
# Resolve container name (CLI arg > Last used > Error).
|
|
||||||
if [[ $image && $image != -* ]]; then
|
|
||||||
shift
|
|
||||||
[[ $image != *:* ]] && image+=":main"
|
|
||||||
mkdir -p "${state_file%/*}" && echo "$image" >"$state_file"
|
|
||||||
elif [[ -f $state_file ]]; then
|
|
||||||
image=$(<$state_file)
|
|
||||||
else
|
|
||||||
die "no container name specified"
|
|
||||||
fi
|
|
||||||
local name="${image%:*}" tag="${image#*:}"
|
|
||||||
image="$name" # config.sh may override (e.g. image=base).
|
|
||||||
|
|
||||||
# Start/Restart if not running or if arguments change configuration.
|
|
||||||
if [[ -z "$(podman ps -q -f name="^$name$" -f status=running)" ]] || (($# > 0)); then
|
|
||||||
log "starting $name:$tag..."
|
|
||||||
|
|
||||||
default_args
|
|
||||||
param_args "$@"
|
|
||||||
|
|
||||||
podman run --replace --stop-timeout 0 -td "${run_opts[@]}" "${DEVC_REGISTRY:-git.plabble.org/job79}/$image:$tag"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec podman exec --detach-keys "ctrl-@,ctrl-@" -it "$name" ${DEVC_COMMAND:-bash -l}
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
podman build . $@ -t git.plabble.org/job79/dev
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Center cursor after moving down half-page" })
|
||||||
|
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Center cursor after moving up half-page" })
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"extras": [
|
||||||
|
"lazyvim.plugins.extras.coding.copilot",
|
||||||
|
"lazyvim.plugins.extras.dap.core",
|
||||||
|
"lazyvim.plugins.extras.lang.go",
|
||||||
|
"lazyvim.plugins.extras.lang.svelte",
|
||||||
|
"lazyvim.plugins.extras.lang.tailwind",
|
||||||
|
"lazyvim.plugins.extras.lang.typescript",
|
||||||
|
"lazyvim.plugins.extras.test.core"
|
||||||
|
],
|
||||||
|
"news": {
|
||||||
|
"NEWS.md": "6520"
|
||||||
|
},
|
||||||
|
"version": 6
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
return {
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
opts = function(_, opts)
|
||||||
|
local cmp = require("cmp")
|
||||||
|
opts.mapping = vim.tbl_deep_extend("force", opts.mapping, {
|
||||||
|
["<CR>"] = cmp.config.disable,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
return {
|
||||||
|
{ "rose-pine/neovim", name = "rose-pine" },
|
||||||
|
{
|
||||||
|
"LazyVim/LazyVim",
|
||||||
|
opts = {
|
||||||
|
colorscheme = "rose-pine-dawn",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"nvimdev/dashboard-nvim",
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferline.nvim",
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
return {
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
opts = {
|
||||||
|
inlay_hints = { enabled = false },
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
. /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\] container | \w \[\e[0;36m\]\[\e[m\] '
|
||||||
|
|
||||||
|
# === aliases and functions ===
|
||||||
|
alias vi=nvim
|
||||||
|
post() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
|
||||||
|
eval "$(zoxide init --cmd cd bash)"
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
. ~/.bashrc
|
||||||
|
|
||||||
|
# === persist copilot auth files inside .local volume ===
|
||||||
|
if [ ! -d ~/.config/github-copilot ]; then
|
||||||
|
mkdir -p ~/.local/share/github-copilot
|
||||||
|
ln -s ~/.local/share/github-copilot ~/.config
|
||||||
|
fi
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
FROM quay.io/fedora/fedora:45
|
|
||||||
|
|
||||||
# === install system packages ===
|
|
||||||
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
|
|
||||||
curl -fsSL -o /etc/yum.repos.d/neovim-nightly.repo \
|
|
||||||
https://copr.fedorainfracloud.org/coprs/agriffis/neovim-nightly/repo/fedora-45/agriffis-neovim-nightly-fedora-45.repo && \
|
|
||||||
dnf update -y && \
|
|
||||||
dnf -y --setopt=keepcache=1 --setopt=install_weak_deps=False install \
|
|
||||||
bash-completion git-core fzf curl awk jq rg unzip which \
|
|
||||||
host-spawn wl-copy gcc tree-sitter-cli diffutils procps-ng file patch neovim
|
|
||||||
|
|
||||||
# === install tools (least to most frequently changing) ===
|
|
||||||
RUN set -o pipefail && \
|
|
||||||
curl -fsSL "$(curl -fsSL https://registry.npmjs.org/@oven/bun-linux-x64/latest | jq -r .dist.tarball)" | \
|
|
||||||
tar xz -C /usr/local/bin --strip-components=2 package/bin/bun && \
|
|
||||||
ln -sf bun /usr/local/bin/bunx && \
|
|
||||||
ln -sf bun /usr/local/bin/node
|
|
||||||
|
|
||||||
RUN set -o pipefail && \
|
|
||||||
curl -fsSL https://claude.ai/install.sh | bash && \
|
|
||||||
cp -L /root/.local/bin/claude /usr/local/bin/ && \
|
|
||||||
rm -rf /root/.local
|
|
||||||
|
|
||||||
COPY ./bin /usr/local/bin
|
|
||||||
COPY ./config/claude.md /etc/claude-code/CLAUDE.md
|
|
||||||
COPY ./config/bashrc /etc/profile.d/devc.sh
|
|
||||||
|
|
||||||
# === environment ===
|
|
||||||
ENV EDITOR=nvim \
|
|
||||||
TZ=Europe/Amsterdam \
|
|
||||||
XDG_RUNTIME_DIR=/run/user/1000 \
|
|
||||||
WAYLAND_DISPLAY=wayland-0 \
|
|
||||||
SSH_AUTH_SOCK=/run/user/1000/ssh-auth-sock \
|
|
||||||
DISABLE_AUTOUPDATER=1
|
|
||||||
|
|
||||||
# === setup user ===
|
|
||||||
RUN useradd -ms /bin/bash user && \
|
|
||||||
echo 'user ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/user && \
|
|
||||||
mkdir -p /run/user/1000 /opt/nvim && \
|
|
||||||
chown user:user /run/user/1000 /opt/nvim
|
|
||||||
|
|
||||||
USER user
|
|
||||||
WORKDIR /home/user
|
|
||||||
|
|
||||||
RUN mkdir -p .config .local .cache && \
|
|
||||||
git clone https://git.plabble.org/Job79/neovim-config.git /opt/nvim && \
|
|
||||||
git -C /opt/nvim remote set-url origin ssh://git@git.plabble.org:2222/Job79/neovim-config.git && \
|
|
||||||
ln -s /opt/nvim .config/nvim
|
|
||||||
|
|
||||||
COPY --chown=user:user ./config/git .config/git/config
|
|
||||||
|
|
||||||
VOLUME /home/user
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=/tmp/bus"
|
|
||||||
[[ -S /tmp/bus ]] || { echo "host-spawn unavailable: restart with 'devc -host-spawn'" >&2; exit 1; }
|
|
||||||
|
|
||||||
cmd="${0##*/}"
|
|
||||||
[[ "$cmd" == "host" ]] && unset cmd
|
|
||||||
exec host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" ${cmd:+"$cmd"} "$@"
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
host
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
host
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# === prompt ===
|
|
||||||
export PS1="\[\e[30;46m\] \h | \w \[\e[0;36m\]\[\e[m\] "
|
|
||||||
|
|
||||||
# === aliases and functions ===
|
|
||||||
alias vi=nvim
|
|
||||||
post() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
|
|
||||||
random() { tr -dc "${2:-A-Za-z0-9!@#$%^&*}" < /dev/urandom | head -c "${1:-32}"; echo; }
|
|
||||||
|
|
||||||
eval "$(fzf --bash)"
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# Environment
|
|
||||||
- Fedora dev container (podman); `sudo dnf install -y <pkg>` for missing tools.
|
|
||||||
- `node` is bun; no python3.
|
|
||||||
- `podman` is available; if it errors, ask the user for permission (restart with `devc -host-spawn`).
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[user]
|
|
||||||
email = job@plabble.org
|
|
||||||
name = Job79
|
|
||||||
signingKey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPsqM6ABAaCTQZ+llFXD3CXrYYuIHDEnvz8IBbXddYEc job@plabble.org
|
|
||||||
[gpg]
|
|
||||||
format = ssh
|
|
||||||
[commit]
|
|
||||||
gpgSign = true
|
|
||||||
[push]
|
|
||||||
autoSetupRemote = true
|
|
||||||
[init]
|
|
||||||
defaultBranch = main
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
image=base
|
|
||||||
run_opts+=("-v" "$HOME/Code/infra:/home/user/Code/infra")
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
ARG TAG=main
|
|
||||||
FROM git.plabble.org/job79/base:${TAG}
|
|
||||||
USER root
|
|
||||||
|
|
||||||
RUN set -o pipefail && \
|
|
||||||
GO_VERSION=$(curl -fsSL "https://go.dev/VERSION?m=text" | head -n 1 | tr -d '\r\n') && \
|
|
||||||
curl -fsSL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" | tar xz -C /usr/local && \
|
|
||||||
ln -sf /usr/local/go/bin/go /usr/local/go/bin/gofmt /usr/local/bin/
|
|
||||||
|
|
||||||
# Build caches live in cache mounts so they don't end up in the image.
|
|
||||||
RUN --mount=type=cache,id=go-mod,target=/root/go/pkg/mod \
|
|
||||||
--mount=type=cache,id=go-build,target=/root/.cache/go-build \
|
|
||||||
for pkg in \
|
|
||||||
golang.org/x/tools/gopls \
|
|
||||||
golang.org/x/tools/cmd/goimports \
|
|
||||||
mvdan.cc/gofumpt \
|
|
||||||
github.com/go-delve/delve/cmd/dlv; \
|
|
||||||
do GOBIN=/usr/local/bin go install "$pkg@latest" || exit 1; done
|
|
||||||
|
|
||||||
RUN --mount=type=cache,id=bun-cache,target=/root/.bun-cache \
|
|
||||||
BUN_INSTALL=/usr/local BUN_INSTALL_CACHE_DIR=/root/.bun-cache bun install -g \
|
|
||||||
typescript typescript-language-server @tailwindcss/language-server svelte-language-server @biomejs/biome
|
|
||||||
|
|
||||||
USER user
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
run_opts+=("-v" "$HOME/Code/go:/home/user/Code/go")
|
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# =============================================== #
|
||||||
|
# enter.sh v1.0; job79 #
|
||||||
|
# Enter into an existing or new dev container and #
|
||||||
|
# automatically handle dev container updates. #
|
||||||
|
# =============================================== #
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# podman_run opens a shell into a newly created dev container.
|
||||||
|
podman_run() {
|
||||||
|
args="--name $name"
|
||||||
|
arg() { args="$args $@"; }
|
||||||
|
|
||||||
|
# Automatically update the container when a newer
|
||||||
|
# image is available.
|
||||||
|
[ "$no_pull" = 1 ] || arg "--pull newer"
|
||||||
|
|
||||||
|
# Disable some security settings to make it possible to mount
|
||||||
|
# host directories without problems.
|
||||||
|
arg "--security-opt label=disable" # disable labeling so mounts don't need to be labbeled.
|
||||||
|
arg "--userns=keep-id" # required for ~/.ssh which is usually 700.
|
||||||
|
arg "--net=host" # use host networking
|
||||||
|
|
||||||
|
# Mount the wayland socket. Required to get the system
|
||||||
|
# clipbard (wl-copy) working.
|
||||||
|
arg "-v /run/user/$UID/wayland-0:/run/user/1000/wayland-0"
|
||||||
|
|
||||||
|
# Mount the ssh socket, directory and git directory. This
|
||||||
|
# gets the host ssh and git configuration working inside
|
||||||
|
# the container.
|
||||||
|
arg "-v $SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock"
|
||||||
|
[ -d ~/.ssh ] && arg "-v $HOME/.ssh:/home/user/.ssh"
|
||||||
|
[ -d ~/.config/git ] && arg "-v $HOME/.config/git:/home/user/.config/git"
|
||||||
|
|
||||||
|
# Mount host directories with programming projects.
|
||||||
|
[ -d ~/Documents ] && arg "-v $HOME/Documents:/home/user/Documents"
|
||||||
|
[ -d ~/.dev ] && arg "-v $HOME/.dev:/home/user/.dev"
|
||||||
|
|
||||||
|
# Add volumes for .local and .cache so these survive
|
||||||
|
# container restarts.
|
||||||
|
arg "-v $name-local:/home/user/.local"
|
||||||
|
arg "-v $name-cache:/home/user/.cache"
|
||||||
|
podman run -it $args "$image"
|
||||||
|
}
|
||||||
|
|
||||||
|
# podman_exec opens a shell into an existing dev container.
|
||||||
|
podman_exec() { podman exec -it "$name" bash -l; }
|
||||||
|
|
||||||
|
# podman_start starts a stopped existing dev container.
|
||||||
|
podman_start() { podman start "$name" 1>/dev/null; }
|
||||||
|
|
||||||
|
# podman_delete deletes a dev container.
|
||||||
|
podman_delete() { podman container rm -f -t 1 "$name" 1>/dev/null; }
|
||||||
|
|
||||||
|
### MAIN ###
|
||||||
|
name="dev"
|
||||||
|
image="git.plabble.org/job79/dev:latest"
|
||||||
|
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case "$1" in
|
||||||
|
--recreate | -r) podman_delete ;;
|
||||||
|
--no-pull | -np) no_pull=1 ;;
|
||||||
|
-*) echo "unknown option '$1'" ;;
|
||||||
|
*) name="$1" ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! podman container exists "$name"; then
|
||||||
|
podman_run
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" = 'true' ]; then
|
||||||
|
podman_exec
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$no_pull" = 1 ]; then
|
||||||
|
podman_start
|
||||||
|
podman_exec
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
iid="$(podman image inspect "$image" -f {{.Id}})"
|
||||||
|
podman pull "$image"
|
||||||
|
if [ "$(podman image inspect "$image" -f {{.Id}})" != "$iid" ]; then
|
||||||
|
# When container is stopped and a newer image is available,
|
||||||
|
# recreate the container instead of starting the existing one.
|
||||||
|
podman_delete
|
||||||
|
podman_run
|
||||||
|
else
|
||||||
|
podman_start
|
||||||
|
podman_exec
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user