Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
882ebfaa00
|
|||
|
b3be78041c
|
|||
|
48f13d622b
|
|||
|
d5ed7bc7f7
|
|||
| 8caa62dc4e | |||
| 4bd0828cbc | |||
| 0aedb01b60 | |||
| c82407fbd2 | |||
| d74c7565bd | |||
| a69e237bd6 | |||
| 9cca35a969 | |||
| b93b0bd735 | |||
| b745a06eec | |||
| 9fbc411dab | |||
| ece5e86a16 | |||
| 065eeedce2 | |||
| 8f4c57d178 | |||
| 09af0db185 | |||
| 9d90ea60f2 | |||
| 790c7c722c | |||
| 35c4f7ed8f | |||
| 8c981a8e8d | |||
| f7da637a1c | |||
| f6bd18cf7d | |||
| 50fc142407 | |||
| 2d7807ea60 | |||
| 5fc464aa6d | |||
| 3560f348a7 | |||
| a0b65c856d | |||
| 393e49c781 | |||
| 9bed5b823f | |||
| 641d1c3050 | |||
| e180de3a7b | |||
| 7fdb0e0fc0 | |||
| 0c76caa267 | |||
| 420d4a287a | |||
| 5bc72a6fb3 | |||
| a1332e1f69 | |||
| d545a9cdf0 | |||
| fedeb5d58d | |||
| fc68b611fe | |||
| 702687276a | |||
| b11b9fd153 | |||
| 5868d34775 | |||
| 6fffe4e0a0 | |||
| 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 |
@@ -0,0 +1,43 @@
|
|||||||
|
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
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
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 +0,0 @@
|
|||||||
state
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM quay.io/fedora/fedora:43
|
FROM quay.io/fedora/fedora:42
|
||||||
|
|
||||||
# === install system packages ===
|
# === install system packages ===
|
||||||
RUN dnf update -y && \
|
RUN dnf update -y && \
|
||||||
@@ -15,8 +15,6 @@ 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
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
. /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 \
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" \
|
if [ "$(basename "$0")" != "host" ]; then
|
||||||
$([ "$(basename "$0")" != "host" ] && echo "$(basename "$0")") "$@"
|
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" $(basename "$0") "$@"
|
||||||
|
else
|
||||||
|
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" "$@"
|
||||||
|
fi
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
for dir in "Code" "Documents" "Downloads" ".config/devcontainer"; do
|
||||||
|
arg "-v $HOME/$dir:/home/user/$dir"
|
||||||
|
done
|
||||||
@@ -1 +0,0 @@
|
|||||||
FROM docker.io/kalilinux/kali-rolling
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
for dir in "Code" "Downloads" ".config/devcontainer"; do
|
||||||
|
arg "-v $HOME/$dir:/home/user/$dir"
|
||||||
|
done
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
#!/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
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
go
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ghcr.io/job79
|
||||||
Reference in New Issue
Block a user