This commit is contained in:
@@ -1,31 +0,0 @@
|
|||||||
# ========================================= #
|
|
||||||
# Containerfile v1.0; job79 #
|
|
||||||
# Configure and setup a neovim devcontainer #
|
|
||||||
# for go and nodejs development. #
|
|
||||||
# ========================================= #
|
|
||||||
FROM quay.io/fedora/fedora:41
|
|
||||||
|
|
||||||
# === setup system ===
|
|
||||||
RUN dnf update -y && \
|
|
||||||
dnf copr enable -y atim/lazygit && \
|
|
||||||
dnf -y install neovim unzip \
|
|
||||||
bash-completion zoxide fd-find chafa lazygit procps \
|
|
||||||
git go npm
|
|
||||||
|
|
||||||
# === setup container user ===
|
|
||||||
RUN useradd -ms /bin/bash user && usermod -aG wheel user && sed -i '/NOPASSWD/s/^#//g' /etc/sudoers
|
|
||||||
RUN mkdir /run/user/1000 && chown user:user /run/user/1000
|
|
||||||
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 /home/user/.config/nvim/lua/config
|
|
||||||
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
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
-- Configure custom keymaps.
|
|
||||||
local keymap = vim.keymap.set
|
|
||||||
local delkeymap = vim.keymap.del
|
|
||||||
local opts = { noremap = true, silent = true }
|
|
||||||
|
|
||||||
-- Improved line start/end
|
|
||||||
keymap({ "n", "v" }, "H", "^", opts)
|
|
||||||
keymap({ "n", "v" }, "L", "$", opts)
|
|
||||||
|
|
||||||
-- Improved escape
|
|
||||||
keymap("n", "<ESC>", "<ESC>:noh<CR>", opts)
|
|
||||||
keymap("t", "<ESC><ESC>", "<C-\\><C-n>", opts)
|
|
||||||
|
|
||||||
-- Disable alt j/k to move lines (conflict with default vim motions)
|
|
||||||
delkeymap({ "i", "v" }, "<A-j>")
|
|
||||||
delkeymap({ "i", "v" }, "<A-k>")
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
|
||||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|
||||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
|
||||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
|
||||||
if vim.v.shell_error ~= 0 then
|
|
||||||
vim.api.nvim_echo({
|
|
||||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
|
||||||
{ out, "WarningMsg" },
|
|
||||||
{ "\nPress any key to exit..." },
|
|
||||||
}, true, {})
|
|
||||||
vim.fn.getchar()
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
vim.opt.rtp:prepend(lazypath)
|
|
||||||
|
|
||||||
require("lazy").setup({
|
|
||||||
spec = {
|
|
||||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
|
||||||
{ import = "plugins" },
|
|
||||||
},
|
|
||||||
defaults = {
|
|
||||||
lazy = false,
|
|
||||||
version = false,
|
|
||||||
},
|
|
||||||
install = {},
|
|
||||||
checker = {
|
|
||||||
enabled = true,
|
|
||||||
notify = true,
|
|
||||||
},
|
|
||||||
performance = {
|
|
||||||
rtp = {
|
|
||||||
disabled_plugins = {
|
|
||||||
"gzip",
|
|
||||||
"netrwPlugin",
|
|
||||||
"tarPlugin",
|
|
||||||
"tohtml",
|
|
||||||
"tutor",
|
|
||||||
"zipPlugin",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
-- Set some custom options.
|
|
||||||
local opt = vim.o
|
|
||||||
local global = vim.g
|
|
||||||
|
|
||||||
-- Set target text width for gww to 60.
|
|
||||||
opt.tw = 60
|
|
||||||
|
|
||||||
-- Use the internal clipboard.
|
|
||||||
opt.clipboard = ""
|
|
||||||
|
|
||||||
-- Use original gruvbox theme.
|
|
||||||
global.gruvbox_material_foreground = "original"
|
|
||||||
|
|
||||||
-- Disable snack animations.
|
|
||||||
global.snacks_animate = false
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"extras": [
|
|
||||||
"lazyvim.plugins.extras.ai.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"
|
|
||||||
],
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
-- Configure rose-pine and gruvbox-material colorschemes.
|
|
||||||
return {
|
|
||||||
{ "rose-pine/neovim", name = "rose-pine" },
|
|
||||||
{ "sainnhe/gruvbox-material" },
|
|
||||||
{
|
|
||||||
"LazyVim/LazyVim",
|
|
||||||
opts = { colorscheme = "gruvbox-material" },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
-- Disable unused plugins and functionality.
|
|
||||||
return {
|
|
||||||
{
|
|
||||||
-- Disable the dashboard.
|
|
||||||
"folke/snacks.nvim",
|
|
||||||
opts = {
|
|
||||||
dashboard = { enabled = false },
|
|
||||||
notifier = { level = vim.log.levels.WARN },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- Disable inline hints by default.
|
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
opts = {
|
|
||||||
inlay_hints = { enabled = false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Disable unused plugins.
|
|
||||||
{ "folke/flash.nvim", enabled = false },
|
|
||||||
{ "folke/todo-comments.nvim", enabled = false },
|
|
||||||
{ "folke/trouble.nvim", enabled = false },
|
|
||||||
{ "MagicDuck/grug-far.nvim", enabled = false },
|
|
||||||
{ "akinsho/bufferline.nvim", enabled = false },
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
. ~/.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
|
|
||||||
20
containers/base/Containerfile
Normal file
20
containers/base/Containerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
FROM quay.io/fedora/fedora:42
|
||||||
|
|
||||||
|
# === install system packages ===
|
||||||
|
RUN dnf update -y && \
|
||||||
|
dnf copr enable -y atim/lazygit && \
|
||||||
|
dnf -y install procps ping bash-completion glibc-langpack-en \
|
||||||
|
host-spawn dbus-launch \
|
||||||
|
zoxide git npm neovim awk jq unzip fd-find chafa lazygit
|
||||||
|
|
||||||
|
# === setup user ===
|
||||||
|
RUN useradd -ms /bin/bash user && \
|
||||||
|
usermod -aG wheel user && sed -i '/NOPASSWD/s/^#//g' /etc/sudoers && \
|
||||||
|
mkdir -p /run/user/1000 && chown user:user /run/user/1000
|
||||||
|
|
||||||
|
USER user
|
||||||
|
WORKDIR /home/user
|
||||||
|
RUN mkdir .config .local .cache
|
||||||
|
COPY --chown=user:user config/bashrc .bashrc
|
||||||
|
COPY config/bin /usr/local/bin
|
||||||
|
VOLUME /home/user
|
||||||
@@ -1,14 +1,21 @@
|
|||||||
. /etc/bashrc
|
. /etc/bashrc
|
||||||
|
|
||||||
|
# === container enter logic - cd to ENTER_DIR ===
|
||||||
|
ENTER_DIR="${ENTER_DIR/#\~/$HOME}"
|
||||||
|
[ -d "$ENTER_DIR" ] && cd "$ENTER_DIR"
|
||||||
|
|
||||||
# === environment ===
|
# === environment ===
|
||||||
export EDITOR=nvim \
|
export EDITOR=nvim \
|
||||||
WAYLAND_DISPLAY=wayland-0 \
|
WAYLAND_DISPLAY=wayland-0 \
|
||||||
XDG_RUNTIME_DIR=/run/user/1000 \
|
XDG_RUNTIME_DIR=/run/user/1000 \
|
||||||
SSH_AUTH_SOCK=/run/user/1000/ssh-auth-sock \
|
SSH_AUTH_SOCK=/run/user/1000/ssh-auth-sock \
|
||||||
PS1='\[\e[30;46m\] container | \w \[\e[0;36m\]\[\e[m\] '
|
DBUS_SESSION_BUS_ADDRESS="unix:path=/tmp/bus" \
|
||||||
|
PS1="\[\e[30;46m\] \h | \w \[\e[0;36m\]\[\e[m\] " \
|
||||||
|
TZ="Europe/Amsterdam"
|
||||||
|
|
||||||
# === aliases and functions ===
|
# === aliases and functions ===
|
||||||
alias vi=nvim
|
alias vi=nvim
|
||||||
post() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
|
post() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
|
||||||
|
|
||||||
eval "$(zoxide init --cmd cd bash)"
|
eval "$(zoxide init --cmd cd bash)"
|
||||||
eval "$(fzf --bash)"
|
eval "$(fzf --bash)"
|
||||||
6
containers/base/config/bin/host
Executable file
6
containers/base/config/bin/host
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if [ "$(basename "$0")" != "host" ]; then
|
||||||
|
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" $(basename "$0") "$@"
|
||||||
|
else
|
||||||
|
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" "$@"
|
||||||
|
fi
|
||||||
1
containers/base/config/bin/podman
Symbolic link
1
containers/base/config/bin/podman
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
host
|
||||||
1
containers/base/config/bin/xdg-open
Symbolic link
1
containers/base/config/bin/xdg-open
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
host
|
||||||
4
containers/go/Containerfile
Normal file
4
containers/go/Containerfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM ghcr.io/job79/base:latest
|
||||||
|
USER root
|
||||||
|
RUN dnf -y install go
|
||||||
|
USER user
|
||||||
3
containers/go/config.sh
Normal file
3
containers/go/config.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
for dir in "Code" "Documents" "Downloads" ".config/devcontainer"; do
|
||||||
|
arg "-v $HOME/$dir:/home/user/$dir"
|
||||||
|
done
|
||||||
4
containers/kube/Containerfile
Normal file
4
containers/kube/Containerfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM ghcr.io/job79/base:latest
|
||||||
|
USER root
|
||||||
|
RUN dnf -y install kubectl
|
||||||
|
USER user
|
||||||
3
containers/kube/config.sh
Normal file
3
containers/kube/config.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
for dir in "Code" "Downloads" ".config/devcontainer"; do
|
||||||
|
arg "-v $HOME/$dir:/home/user/$dir"
|
||||||
|
done
|
||||||
67
enter.sh
67
enter.sh
@@ -1,29 +1,36 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# =============================================== #
|
# =============================================== #
|
||||||
# enter.sh v1.0; job79 #
|
# enter.sh v2.0; job79 #
|
||||||
# Enter into an existing or new dev container and #
|
# Dev container enter script. Handles setting up #
|
||||||
# automatically handle dev container updates. #
|
# different dev containers, resuming sessions and #
|
||||||
|
# automatic container updates. #
|
||||||
# =============================================== #
|
# =============================================== #
|
||||||
set -eu
|
set -eu
|
||||||
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-○}" "$1"; }
|
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-○}" "$1"; }
|
||||||
arg() { echo -n " $@"; }
|
arg() { echo -n " $@"; }
|
||||||
|
|
||||||
# run_args returns the arguments required for the podman run
|
# run_args returns the podman run arguments required for
|
||||||
# command.
|
# starting a new container.
|
||||||
run_args() {
|
run_args() {
|
||||||
arg "--name $name"
|
arg "--name $name"
|
||||||
|
|
||||||
# Disable some security settings to make it possible to
|
# Disable some security settings so host directories can
|
||||||
# mount host directories without problems.
|
# be mounted without problems.
|
||||||
arg "--security-opt label=disable" # disable labeling so mounts don't need to be labeled.
|
arg "--security-opt label=disable" # disable labeling so mounts don't need to be labeled.
|
||||||
arg "--userns=keep-id" # required for ~/.ssh which is usually 700.
|
arg "--userns=keep-id" # required for ~/.ssh which is usually 700.
|
||||||
|
|
||||||
|
# Configure options to get host-spawn to work inside the
|
||||||
|
# container.
|
||||||
|
[ -e "/run/user/$UID/bus" ] && arg "-v /run/user/$UID/bus:/tmp/bus" # Use host dbus.
|
||||||
|
arg "-e HOST_HOME=$HOME" # Used to translate container path to host.
|
||||||
|
|
||||||
# Use host networking.
|
# Use host networking.
|
||||||
arg "--net=host"
|
arg "--net=host"
|
||||||
|
|
||||||
# Mount the wayland socket. Required to get the system
|
# Mount the wayland socket. Required to get the system
|
||||||
# clipbard (wl-copy) working.
|
# clipbard (wl-copy) and gui applications working.
|
||||||
[ -e "/run/user/$UID/wayland-0" ] && arg "-v /run/user/$UID/wayland-0:/run/user/1000/wayland-0"
|
[ -e "/run/user/$UID/wayland-0" ] && arg "-v /run/user/$UID/wayland-0:/run/user/1000/wayland-0"
|
||||||
|
arg "--device /dev/dri" # mount gpu devices for gpu acceleration.
|
||||||
|
|
||||||
# Mount the ssh socket, directory and the git config
|
# Mount the ssh socket, directory and the git config
|
||||||
# directory. This gets the host ssh and git configuration
|
# directory. This gets the host ssh and git configuration
|
||||||
@@ -32,41 +39,47 @@ run_args() {
|
|||||||
[ -d "$HOME/.ssh" ] && arg "-v $HOME/.ssh:/home/user/.ssh"
|
[ -d "$HOME/.ssh" ] && arg "-v $HOME/.ssh:/home/user/.ssh"
|
||||||
[ -d "$HOME/.config/git" ] && arg "-v $HOME/.config/git:/home/user/.config/git"
|
[ -d "$HOME/.config/git" ] && arg "-v $HOME/.config/git:/home/user/.config/git"
|
||||||
|
|
||||||
# Mount host directories with programming projects.
|
# Add a volume for the home directory so it survives
|
||||||
[ -d "$HOME/Code" ] && arg "-v $HOME/Code:/home/user/Code"
|
# container updates.
|
||||||
[ -d "$HOME/.config/devcontainer" ] && arg "-v $HOME/.config/devcontainer:/home/user/.dev"
|
arg "-v $name:/home/user:copy"
|
||||||
|
|
||||||
# Add volumes for .local and .cache so these survive
|
# Add custom user configuration.
|
||||||
# container restarts.
|
config_file="$script_dir/containers/$name/config.sh"
|
||||||
arg "-v $name-local:/home/user/.local"
|
[ -f "${config_file}" ] && source "${config_file}"
|
||||||
arg "-v $name-cache:/home/user/.cache"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
### MAIN ###
|
### MAIN ###
|
||||||
name="dev"
|
script_dir="$(dirname "$(realpath "$0")")"
|
||||||
image="git.plabble.org/job79/devcontainer:latest"
|
name=$(<"$script_dir/state/last-name")
|
||||||
fetch=false
|
registry=$(<"$script_dir/state/registry")
|
||||||
|
pull=false
|
||||||
|
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--image | -i) shift && fetch=true && image="$1" ;;
|
-p) pull=true ;;
|
||||||
--fetch | -f) fetch=true ;;
|
|
||||||
-*) log "unknown argument '$1'" 'x' 31 ;;
|
-*) log "unknown argument '$1'" 'x' 31 ;;
|
||||||
*) name="$1" ;;
|
*)
|
||||||
|
name="$1"
|
||||||
|
echo "$1" >"$script_dir/state/last-name"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$fetch" = true ] || [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ]; then
|
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ] || [ "$pull" = true ]; then
|
||||||
log "fetching devcontainer updates..."
|
log "fetching devcontainer updates..."
|
||||||
if [ "$(podman pull -q "$image" 2>&1)" != "$(podman container inspect "$name" -f {{.Image}} 2>&1)" ]; then
|
if [ "$(podman container inspect "$name" -f {{.Image}} 2>&1)" != "$(podman pull -q "$registry/$name" 2>&1)" ] || [ "$pull" = true ]; then
|
||||||
log "container image downloaded" '✓' 32
|
if [ $? -eq 0 ]; then
|
||||||
|
log "container image downloaded" '✓' 32
|
||||||
|
else
|
||||||
|
log "failed to download container image" 'x' 31
|
||||||
|
fi
|
||||||
podman container rm -f -t 1 "$name" 1>/dev/null
|
podman container rm -f -t 1 "$name" 1>/dev/null
|
||||||
podman run -td $(run_args) "$image"
|
podman run -td $(run_args) "$registry/$name"
|
||||||
else
|
else
|
||||||
log "no updates available" '✓' 32
|
log "no updates available" '✓' 32
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
podman start "$name" 1>/dev/null
|
podman start "$name" 1>/dev/null
|
||||||
podman exec --detach-keys "" -it "$name" bash -l
|
podman exec -e ENTER_DIR="${PWD/#$HOME/\~}" --detach-keys "ctrl-@" -it "$name" bash -l
|
||||||
|
|||||||
1
state/last-name
Normal file
1
state/last-name
Normal file
@@ -0,0 +1 @@
|
|||||||
|
go
|
||||||
1
state/registry
Normal file
1
state/registry
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ghcr.io/job79
|
||||||
Reference in New Issue
Block a user