45 Commits

Author SHA1 Message Date
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 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 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 2026-02-22 16:35:22 +01:00
6d817d31cd feat: upgrade to fedora 44 2026-02-22 15:56:09 +01:00
2f0327fa55 ci: build for arm 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 2026-02-21 10:41:36 +01:00
dc2f2991bc feat: add lazysql 2026-02-21 10:41:17 +01:00
10f0f5993b feat: add lazydocker 2026-02-20 20:59:02 +01:00
8f761565d0 fix: php install 2026-01-29 16:19:56 +01:00
86e3275c67 feat: add php container 2026-01-29 16:10:08 +01:00
e6bd3f3524 fix: permissions of /run/user/1000 2026-01-11 15:50:14 +01:00
4e1737f5b3 ci: add dnf cache 2025-12-29 17:00:17 +01:00
32bbe1c2cd ci: remove zstd:chunked because it is causing issues with /run 2025-12-29 15:32:35 +01:00
678b8bee6e fix: /run issue in infra container 2025-12-28 12:08:42 +01:00
0d3d5d5b36 ci: add manual trigger 2025-12-28 11:04:33 +01:00
8bde490c6d fix(ci): avoid pulling fedora container 2025-12-28 10:49:43 +01:00
cdbb4de204 fix: permissions of /run directory 2025-12-27 20:33:12 +01:00
9b81bc8c68 feat(ci): build using podman for zstd:chunked and only build changed containers 2025-12-27 20:33:12 +01:00
40bb6328c4 fix: update dockerfiles 2025-12-27 14:29:15 +01:00
c137f16ddf chore: remve -kvm and -usb
Better to just use the podman flags, they are very similair
2025-12-27 14:08:57 +01:00
057c72e3a0 feat: install sops and age into infra container 2025-12-24 10:16:35 +01:00
062972a440 chore: remove vms container 2025-12-24 10:04:47 +01:00
723d2fd984 feat: add k9s 2025-12-14 19:32:26 +01:00
03df535d76 feat: add fluxcd to infra container 2025-11-16 14:25:21 +01:00
d6ef16cd24 fix: disable seccomp for vms container 2025-11-12 17:07:51 +01:00
a0ea04d2bd chore: remove kali container 2025-11-12 16:55:15 +01:00
d7468a444b feat: add vms path 2025-11-11 09:01:14 +01:00
f25b6966ef fix: enable gpu for vms container 2025-11-10 19:58:47 +01:00
9f1b65b781 refactor: add spacing to dockerfiles 2025-11-10 17:59:48 +01:00
d81fa7d3a1 feat: add vms devcontainer 2025-11-10 17:57:21 +01:00
7e27784a9a chore: change code path 2025-11-04 16:26:11 +01:00
b5dd280e5a feat: add /mnt flag 2025-10-31 11:57:26 +01:00
bb43c758f9 feat: add -usb and -kvm flags 2025-10-31 11:43:28 +01:00
19 changed files with 240 additions and 239 deletions

108
.gitea/workflows/build.yaml Normal file
View File

@@ -0,0 +1,108 @@
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"
jobs:
changes:
runs-on: job-v2
outputs:
base: ${{ steps.filter.outputs.base == 'true' }}
infra: ${{ steps.filter.outputs.infra == 'true' || steps.filter.outputs.base == 'true' }}
go: ${{ steps.filter.outputs.go == 'true' || steps.filter.outputs.base == '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'}}
steps:
- uses: actions/checkout@v4
- uses: https://github.com/dorny/paths-filter@v3
id: filter
with:
filters: |
workflow: ['.gitea/workflows/build.yaml']
base: ['containers/base/**']
infra: ['containers/infra/**']
go: ['containers/go/**']
php: ['containers/php/**']
base-image:
needs: [changes]
if: ${{ needs.changes.outputs.base == 'true' || needs.changes.outputs.any_change == 'true' }}
runs-on: job-v2
steps:
- uses: actions/checkout@v4
- name: Log in
uses: redhat-actions/podman-login@v1
with:
registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build
id: build
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
with:
image: job79/base
tags: ${{ github.ref_name }}
context: ./containers/base
containerfiles: ./containers/base/Containerfile
platforms: linux/amd64
- name: Push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
extra-args: |
--compression-format=zstd
--compression-level=12
dependent-images:
needs: [changes, base-image]
if: always() && needs.changes.result == 'success' && (needs.base-image.result == 'success' || needs.base-image.result == 'skipped') && (needs.changes.outputs[matrix.container] == 'true' || needs.changes.outputs.any_change == 'true')
runs-on: job-v2
strategy:
fail-fast: false
matrix:
container: [infra, go, php]
steps:
- name: Clone repo
if: steps.check.outputs.run == 'true'
uses: actions/checkout@v4
- name: Log in
if: steps.check.outputs.run == 'true'
uses: redhat-actions/podman-login@v1
with:
registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build
id: build
if: steps.check.outputs.run == 'true'
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
with:
image: job79/${{ matrix.container }}
tags: ${{ github.ref_name }}
context: ./containers/${{ matrix.container }}
containerfiles: ./containers/${{ matrix.container }}/Containerfile
build-args: TAG=${{ github.ref_name }}
platforms: linux/amd64
- name: Push
if: steps.check.outputs.run == 'true'
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
extra-args: |
--compression-format=zstd
--compression-level=12

View File

@@ -1,60 +0,0 @@
name: Build container
on:
push:
branches: ["main"]
paths:
- "containers/fedora/**"
- "containers/go/**"
- "containers/infra/**"
- ".gitea/workflows/fedora.yaml"
pull_request:
branches: ["main"]
paths:
- "containers/fedora/**"
- "containers/go/**"
- "containers/infra/**"
- ".gitea/workflows/fedora.yaml"
schedule:
- cron: "0 16 * * FRI"
jobs:
fedora-build:
runs-on: job-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- 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 fedora container
uses: docker/build-push-action@v5
with:
context: ./containers/fedora
file: ./containers/fedora/Containerfile
push: true
tags: git.plabble.org/job79/fedora:${{ github.ref_name }}
build-args: TAG=${{ github.ref_name }}
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
- name: Build and push go container
uses: docker/build-push-action@v5
with:
context: ./containers/go
file: ./containers/go/Containerfile
push: true
tags: git.plabble.org/job79/go:${{ github.ref_name }}
build-args: TAG=${{ github.ref_name }}
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
- name: Build and push infra container
uses: docker/build-push-action@v5
with:
context: ./containers/infra
file: ./containers/infra/Containerfile
push: true
tags: git.plabble.org/job79/infra:${{ github.ref_name }}
build-args: TAG=${{ github.ref_name }}
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true

View File

@@ -1,37 +0,0 @@
name: Build container
on:
push:
branches: ["main"]
paths:
- "containers/kali/**"
- ".gitea/workflows/kali.yaml"
pull_request:
branches: ["main"]
paths:
- "containers/kali/**"
- ".gitea/workflows/kali.yaml"
schedule:
- cron: "0 16 * * FRI"
jobs:
kali-build:
runs-on: job-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- 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 kali container
uses: docker/build-push-action@v5
with:
context: ./containers/kali
file: ./containers/kali/Containerfile
push: true
tags: git.plabble.org/job79/kali:${{ github.ref_name }}
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true

View File

@@ -0,0 +1,31 @@
FROM quay.io/fedora/fedora:44
# === 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 copr enable -y gierth/tools-golang && \
dnf copr enable -y agriffis/neovim-nightly && \
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 lazysql
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

@@ -1,13 +1,14 @@
. /etc/bashrc
source /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\] " \
export EDITOR="nvim" \
WAYLAND_DISPLAY="wayland-0" \
XDG_RUNTIME_DIR="/run/user/1000" \
SSH_AUTH_SOCK="/run/user/1000/ssh-auth-sock" \
TZ="Europe/Amsterdam"
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; }

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 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 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
RUN 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,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,5 +1,8 @@
ARG TAG
FROM git.plabble.org/job79/fedora:${TAG}
FROM job79/base:${TAG}
USER root
RUN dnf -y install go
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y --setopt=keepcache=1 install go
USER user

View File

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

View File

@@ -1,6 +1,10 @@
ARG TAG
FROM git.plabble.org/job79/fedora:${TAG}
FROM job79/base:${TAG}
USER root
RUN dnf -y install kubectl openssl
RUN curl -sL https://talos.dev/install | sh
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-.*.$(arch).rpm\$\")) | .browser_download_url")" && \
curl -sL https://talos.dev/install | sh && \
curl -s https://fluxcd.io/install.sh | bash
USER user

View File

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

View File

@@ -1,17 +0,0 @@
FROM docker.io/kalilinux/kali-rolling
# === install system packages ===
RUN apt update && \
apt -y install iputils-ping sudo \
zoxide git npm neovim gawk jq unzip fd-find lazygit
# === setup user ===
RUN useradd -ms /bin/bash user && \
usermod -aG sudo user && sed -i 's/^%sudo\s\+ALL=(ALL:ALL)\s\+ALL$/%sudo\tALL=(ALL:ALL)\tNOPASSWD: ALL/' /etc/sudoers && \
mkdir -p /run/user/1000 && chown user:user /run/user/1000
USER user
WORKDIR /home/user
RUN mkdir -p .config .local .cache
RUN git clone https://git.plabble.org/Job79/neovim-config.git .config/nvim
VOLUME /home/user

View File

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

2
containers/php/config.sh Normal file
View File

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

145
devc.sh
View File

@@ -1,108 +1,87 @@
#!/bin/bash
# =============================================== #
# devc.sh v2.0; job79 #
# Dev container enter script. Handles setting up #
# different dev containers, resuming sessions and #
# automatic container updates. #
# devc.sh v2.1; job79, maurice #
# Dev container entry script. #
# =============================================== #
set -eu
set -euo pipefail
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-}" "$1"; }
arg() { echo -n " $@"; }
die() { log "$1" 'x' 31 && exit 1; }
# run_args returns the podman run arguments required for
# starting a new container.
# default_args configures standard container options.
default_args() {
arg "--name $name"
arg "--hostname $name"
run_opts+=(
"--name" "$name"
"--hostname" "$name"
"--pull=newer" # Update image.
"--userns=keep-id" # Map host user.
"--net=devc" # Shared network.
"-v" "$name:/home/user:copy" # Persistent home volume.
)
# Pull newer container image if available.
arg "--pull=newer"
# Unix sockets require SELinux label disable.
[[ -d /sys/fs/selinux ]] && run_opts+=("--security-opt" "label=disable")
# Use keep-id so the container user matches the host user.
arg "--userns=keep-id"
# 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")
# Disable selinux labeling so unix sockets can be mounted
# without problems.
arg "--security-opt label=disable"
# 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}"
# Load custom container config.
local config_file="${BASH_SOURCE[0]%/*}/containers/$name/config.sh"
[[ -f "$config_file" ]] && source "$config_file" || true
}
# param_args returns the podman run arguments based on the
# arguments provided to this script.
# param_args parses CLI arguments into podman run options.
param_args() {
while test $# -gt 0; do
while (($# > 0)); do
case "$1" in
-gpu) # Enable gpu acceleration.
arg "--device /dev/dri" ;;
-host-spawn) # Enable spawning host commands from inside the container using host-spawn.
arg "-v /run/user/$UID/bus:/tmp/bus"
arg "-e HOST_HOME=$HOME" # Used to translate paths.
-gpu) run_opts+=("--device" "/dev/dri") ;;
-host-spawn) run_opts+=("-v" "/run/user/$UID/bus:/tmp/bus" "-e" "HOST_HOME=$HOME") ;;
-container-sock) run_opts+=("-v" "${XDG_RUNTIME_DIR:-/run/user/$UID}/podman/podman.sock:/var/run/docker.sock") ;;
-x11)
run_opts+=("-v" "/tmp/.X11-unix:/tmp/.X11-unix" "-v" "${XAUTHORITY:-$HOME/.Xauthority}:/run/user/1000/.Xauthority:ro")
run_opts+=("-e" "DISPLAY=${DISPLAY:-:0}" "-e" "XAUTHORITY=/run/user/1000/.Xauthority")
;;
-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)
local type=''
[[ ! -d "$2" ]] && type='file'
run_opts+=("-w" "/mnt/" "-v" "$2:/mnt/$type")
shift
;;
*) # Use unknown arguments a podman arguments.
arg "$1" ;;
*) run_opts+=("$1") ;;
esac
shift
done
}
### MAIN ###
# Get the devcontainer name from the first argument. If not
# provided, use the last used name when possible.
if [[ $# -gt 0 ]] && [[ ${1:-} != -* ]]; then
image="$1"
[[ "$image" != *:* ]] && image="$image:main"
echo "$image" >"$HOME/.local/share/devc-previous-container"
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
elif [ -f "$HOME/.local/share/devc-previous-container" ]; then
image=$(<"$HOME/.local/share/devc-previous-container")
else
log "no container name specified" 'x' 31
exit 1
fi
name="${image%:*}"
[[ $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%:*}"
# Get container registry from the DEVC_REGISTRY env
# variable.
if [ -n "${DEVC_REGISTRY:-}" ]; then
registry="$DEVC_REGISTRY"
else
log "registry unknown; set the DEVC_REGISTRY environment variable" 'x' 31
exit 1
fi
# 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 $image..."
[[ -n "${DEVC_REGISTRY:-}" ]] || die "registry unknown; set the DEVC_REGISTRY environment variable"
# Get container command from the DEVC_COMMAND env variable
# if set, else use bash -l.
if [ -z "${DEVC_COMMAND:-}" ]; then
DEVC_COMMAND="bash -l"
fi
default_args
param_args "$@"
# When container is not running or arguments are provided,
# recreate it.
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ] || [[ $# -gt 0 ]]; then
log "starting devcontainer..."
podman container rm -f -t 0 "$name" 1>/dev/null
podman run -td $(default_args) $(param_args $@) "$registry/$image"
fi
podman network create --ignore "devc" &>/dev/null
podman run --replace --stop-timeout 0 -td "${run_opts[@]}" "$DEVC_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 "$@"