Compare commits

..

35 Commits

Author SHA1 Message Date
Job79 0f95243db5 feat: add kali container
Build container / base-build (push) Failing after 2m51s
Build container / go-build (push) Has been skipped
Build container / infra-build (push) Has been skipped
Build container / kali-build (push) Has been skipped
2025-10-13 11:27:56 +02:00
Job79 105e63f05b feat: make container builds parallel 2025-10-12 12:12:34 +02:00
Job79 060e333c8f feat: reintroduce per container config 2025-10-12 12:06:57 +02:00
Job79 87350e7efe chore: add state to gitignore 2025-10-12 12:04:47 +02:00
Job79 c32721c49c feat: clone nvim config 2025-10-12 12:02:25 +02:00
Job79 e3d9dfd392 refactor: cleanup scripts and config 2025-10-12 11:55:22 +02:00
Job79 2770628074 chore: update to fedora 43 2025-09-08 15:32:21 +02:00
Job79 4004417aa5 refactor: use hostname instead of variable 2025-09-01 10:26:07 +02:00
Job79 e0f953b94e fix: keep directory when entering container 2025-08-27 21:16:03 +02:00
Job79 cfb894c2eb fix: always pull when -p flag is used 2025-08-27 21:08:03 +02:00
Job79 27024a0158 refactor: restrict container host access 2025-08-27 21:03:38 +02:00
Job79 2f41c16957 feat: allow calling host script without symlink 2025-08-27 20:54:38 +02:00
Job79 e193a14dee feat: support gui applications 2025-08-27 20:49:37 +02:00
Job79 2ee75a2f91 feat: build multiple image 2025-08-27 20:34:47 +02:00
Job79 fee028121c feat: add ping to dockerfile 2025-08-14 12:59:35 +02:00
Job79 8e4e2b9aa2 fix: problems with host-spawn 2025-07-18 21:50:50 +02:00
Job79 388da00743 feat: add support for host-spawn 2025-07-18 21:10:12 +02:00
Job79 1063e6d565 chore: remove dotnet 2025-07-11 15:53:14 +02:00
Job79 f85a6740c5 feat(enter): restore directory on container enter 2025-06-27 17:16:08 +02:00
Job79 34a5c009f0 feat(enter): add documents directory 2025-06-27 17:00:39 +02:00
Job79 0ac7ced200 feat(container): add jq and dotnet 2025-06-27 16:59:04 +02:00
Job79 27e0ab59f7 chore: re-enable zstd compression 2025-05-27 20:33:29 +02:00
Job79 4e7a3c1cf3 chore(Containerfile): add awk 2025-03-24 20:52:29 +01:00
Job79 f7cf06f26f chore: update fedora to version 42 2025-03-01 10:52:39 +01:00
Job79 a0a383051f fix(Containerfile): placement of comments 2025-01-25 16:12:22 +01:00
Job79 b6efe55600 refactor: move neovim-config to different repo and mount whole home as volume 2025-01-25 16:03:59 +01:00
Job79 8fa4fa1037 ci: use branch name as tag 2025-01-25 15:47:41 +01:00
Job79 f78479fea7 ci: disable zstd:chunked for now because it is a lot slower 2024-12-22 15:58:20 +01:00
Job79 c0145ade3d feat: switch to rose-pine-dawn theme by default 2024-12-22 15:57:33 +01:00
Job79 7828f94011 fix: hide podman pull errors 2024-12-22 15:03:09 +01:00
Job79 8f4539b1a0 refactor: rename dockerfile to containerfile 2024-12-21 15:36:50 +01:00
Job79 559e6a1d3c ci: use zstd:chunked 2024-12-21 11:16:48 +01:00
Job79 91cbdda9b8 ci: use podman for container builds 2024-12-21 11:11:13 +01:00
Job79 05f2a0690e ci: use repo name 2024-12-21 10:53:30 +01:00
Job79 9aa384c1a3 init 2024-12-21 10:36:08 +01:00
15 changed files with 191 additions and 146 deletions
-43
View File
@@ -1,43 +0,0 @@
name: Build container
on:
push:
pull_request:
branches: ["main"]
schedule:
- cron: "0 16 * * FRI"
jobs:
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 base container
uses: docker/build-push-action@v5
with:
context: ./containers/base
file: ./containers/base/Containerfile
push: true
tags: git.plabble.org/job79/base:latest
- 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:latest
- name: Build and push kube container
uses: docker/build-push-action@v5
with:
context: ./containers/kube
file: ./containers/kube/Containerfile
push: true
tags: git.plabble.org/job79/kube:latest
+77
View File
@@ -0,0 +1,77 @@
name: Build container
on:
push:
pull_request:
branches: ["main"]
schedule:
- cron: "0 16 * * FRI"
jobs:
base-build:
runs-on: ubuntu-24.04
steps:
- &clone_repo
name: Clone repo
uses: actions/checkout@v4
- &setup_buildx
name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- &login_registry
name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push base container
uses: docker/build-push-action@v5
with:
context: ./containers/base
file: ./containers/base/Containerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/base:latest
go-build:
runs-on: ubuntu-24.04
needs: base-build
steps:
- *clone_repo
- *setup_buildx
- *login_registry
- name: Build and push go container
uses: docker/build-push-action@v5
with:
context: ./containers/go
file: ./containers/go/Containerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/go:latest
infra-build:
runs-on: ubuntu-24.04
needs: base-build
steps:
- *clone_repo
- *setup_buildx
- *login_registry
- name: Build and push infra container
uses: docker/build-push-action@v5
with:
context: ./containers/infra
file: ./containers/infra/Containerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/infra:latest
kali-build:
runs-on: ubuntu-24.04
needs: base-build
steps:
- *clone_repo
- *setup_buildx
- *login_registry
- name: Build and push kali container
uses: docker/build-push-action@v5
with:
context: ./containers/kali
file: ./containers/kali/Containerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/kali:latest
+1
View File
@@ -0,0 +1 @@
state
+3 -1
View File
@@ -1,4 +1,4 @@
FROM quay.io/fedora/fedora:42 FROM quay.io/fedora/fedora:43
# === install system packages === # === install system packages ===
RUN dnf update -y && \ RUN dnf update -y && \
@@ -15,6 +15,8 @@ RUN useradd -ms /bin/bash user && \
USER user USER user
WORKDIR /home/user WORKDIR /home/user
RUN mkdir .config .local .cache 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/bashrc .bashrc
COPY --chown=user:user config/git .config/git/config
COPY config/bin /usr/local/bin COPY config/bin /usr/local/bin
VOLUME /home/user VOLUME /home/user
-4
View File
@@ -1,9 +1,5 @@
. /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 \
+2 -5
View File
@@ -1,6 +1,3 @@
#!/bin/bash #!/bin/bash
if [ "$(basename "$0")" != "host" ]; then host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" \
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" $(basename "$0") "$@" $([ "$(basename "$0")" != "host" ] && echo "$(basename "$0")") "$@"
else
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" "$@"
fi
+12
View File
@@ -0,0 +1,12 @@
[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
-3
View File
@@ -1,3 +0,0 @@
for dir in "Code" "Documents" "Downloads" ".config/devcontainer"; do
arg "-v $HOME/$dir:/home/user/$dir"
done
+1
View File
@@ -0,0 +1 @@
FROM docker.io/kalilinux/kali-rolling
-3
View File
@@ -1,3 +0,0 @@
for dir in "Code" "Downloads" ".config/devcontainer"; do
arg "-v $HOME/$dir:/home/user/$dir"
done
Executable
+95
View File
@@ -0,0 +1,95 @@
#!/bin/bash
# =============================================== #
# devc.sh v2.0; job79 #
# Dev container enter script. Handles setting up #
# different dev containers, resuming sessions and #
# automatic container updates. #
# #
# TODO: #
# - Remove security-opt label=disable #
# when possible. #
# - Look into removeing userns=keep-id. #
# - Isolate ssh keys to containers. #
# =============================================== #
set -eu
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-}" "$1"; }
arg() { echo -n " $@"; }
# run_args returns the podman run arguments required for
# starting a new container.
default_args() {
arg "--name $name"
arg "--hostname $name"
arg "--pull=newer"
# Disable some security settings so host directories can
# be mounted without problems.
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.
# 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 commands working.
[ -e "$SSH_AUTH_SOCK" ] && arg "-v $SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock"
# Load custom configuration for container.
config_file="$script_dir/containers/$name/config.sh"
[ -f "${config_file}" ] && source "${config_file}"
# Add a volume for the home directory so it survives
# container updates.
arg "-v $name:/home/user:copy"
}
# param_args returns the podman run arguments based on the
# arguments provided to this script.
param_args() {
while test $# -gt 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" ;;
*) # Use argument as is.
echo "$1" ;;
esac
shift
done
}
### MAIN ###
script_dir="$(dirname "$(realpath "$0")")"
# Get container registry from 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
# Get the devcontainer name from the first argument. If not
# provided, use the last used name when possible.
if [[ $# -gt 0 ]] && [[ ${1:-} != -* ]]; then
name="$1"
mkdir -p "$script_dir/state"
echo "$name" >"$script_dir/state/last-name"
shift
elif [ -f "$script_dir/state/last-name" ]; then
name=$(<"$script_dir/state/last-name")
else
log "no container name specified" 'x' 31
exit 1
fi
# Create a new container when the container is not running or
# when any arguments are provided.
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/$name"
fi
podman exec -it "$name" bash -l
-85
View File
@@ -1,85 +0,0 @@
#!/bin/bash
# =============================================== #
# enter.sh v2.0; job79 #
# Dev container enter script. Handles setting up #
# different dev containers, resuming sessions and #
# automatic container updates. #
# =============================================== #
set -eu
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-}" "$1"; }
arg() { echo -n " $@"; }
# run_args returns the podman run arguments required for
# starting a new container.
run_args() {
arg "--name $name"
# Disable some security settings so host directories can
# be mounted without problems.
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.
# 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.
arg "--net=host"
# Mount the wayland socket. Required to get the system
# 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"
arg "--device /dev/dri" # mount gpu devices for gpu acceleration.
# Mount the ssh socket, directory and the git config
# directory. This gets the host ssh and git configuration
# working inside the container.
[ -e "$SSH_AUTH_SOCK" ] && arg "-v $SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock"
[ -d "$HOME/.ssh" ] && arg "-v $HOME/.ssh:/home/user/.ssh"
[ -d "$HOME/.config/git" ] && arg "-v $HOME/.config/git:/home/user/.config/git"
# Add a volume for the home directory so it survives
# container updates.
arg "-v $name:/home/user:copy"
# Add custom user configuration.
config_file="$script_dir/containers/$name/config.sh"
[ -f "${config_file}" ] && source "${config_file}"
}
### MAIN ###
script_dir="$(dirname "$(realpath "$0")")"
name=$(<"$script_dir/state/last-name")
registry=$(<"$script_dir/state/registry")
pull=false
while test $# -gt 0; do
case "$1" in
-p) pull=true ;;
-*) log "unknown argument '$1'" 'x' 31 ;;
*)
name="$1"
echo "$1" >"$script_dir/state/last-name"
;;
esac
shift
done
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ] || [ "$pull" = true ]; then
log "fetching devcontainer updates..."
if [ "$(podman container inspect "$name" -f {{.Image}} 2>&1)" != "$(podman pull -q "$registry/$name" 2>&1)" ] || [ "$pull" = true ]; then
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 run -td $(run_args) "$registry/$name"
else
log "no updates available" '✓' 32
fi
fi
podman start "$name" 1>/dev/null
podman exec -e ENTER_DIR="${PWD/#$HOME/\~}" --detach-keys "ctrl-@" -it "$name" bash -l
-1
View File
@@ -1 +0,0 @@
go
-1
View File
@@ -1 +0,0 @@
ghcr.io/job79