Compare commits
38 Commits
0f95243db5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
03df535d76
|
|||
|
d6ef16cd24
|
|||
|
a0ea04d2bd
|
|||
|
d7468a444b
|
|||
|
f25b6966ef
|
|||
|
9f1b65b781
|
|||
|
d81fa7d3a1
|
|||
|
7e27784a9a
|
|||
|
b5dd280e5a
|
|||
|
bb43c758f9
|
|||
|
407ba8afae
|
|||
|
aa3d5d5bb8
|
|||
|
28766d5e87
|
|||
|
51f7e95104
|
|||
|
497d4e76d0
|
|||
|
6ae5ff5a6c
|
|||
|
611c16a087
|
|||
|
26266017c2
|
|||
|
c6fa393c03
|
|||
| 27d2f05a3d | |||
| 72c7271163 | |||
| 927e4ad227 | |||
| fa489baac7 | |||
| eea31f47e7 | |||
| 6fa3dba208 | |||
| 478464c6ad | |||
| 883e7fbfa5 | |||
| ceb10fc051 | |||
| f39c7939e5 | |||
| 1ffd6e8477 | |||
| a406a9cc00 | |||
| 1056536891 | |||
| 56e4c89398 | |||
|
46ff2edef9
|
|||
|
0fd865e8e0
|
|||
|
34bb6f8ea0
|
|||
|
97c3a83496
|
|||
|
475cbeec03
|
69
.gitea/workflows/fedora.yaml
Normal file
69
.gitea/workflows/fedora.yaml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
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
|
||||||
|
- name: Build and push vms container
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ./containers/vms
|
||||||
|
file: ./containers/vms/Containerfile
|
||||||
|
push: true
|
||||||
|
tags: git.plabble.org/job79/vms:${{ github.ref_name }}
|
||||||
|
build-args: TAG=${{ github.ref_name }}
|
||||||
|
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
|
||||||
77
.github/workflows/ci.yaml
vendored
77
.github/workflows/ci.yaml
vendored
@@ -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
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
state
|
|
||||||
@@ -5,7 +5,7 @@ RUN dnf update -y && \
|
|||||||
dnf copr enable -y atim/lazygit && \
|
dnf copr enable -y atim/lazygit && \
|
||||||
dnf -y install procps ping bash-completion glibc-langpack-en \
|
dnf -y install procps ping bash-completion glibc-langpack-en \
|
||||||
host-spawn dbus-launch \
|
host-spawn dbus-launch \
|
||||||
zoxide git npm neovim awk jq unzip fd-find chafa lazygit
|
zoxide git npm neovim awk jq unzip fd-find lazygit
|
||||||
|
|
||||||
# === setup user ===
|
# === setup user ===
|
||||||
RUN useradd -ms /bin/bash user && \
|
RUN useradd -ms /bin/bash user && \
|
||||||
@@ -15,8 +15,10 @@ 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
|
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 --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
|
||||||
@@ -5,7 +5,6 @@ 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 \
|
||||||
DBUS_SESSION_BUS_ADDRESS="unix:path=/tmp/bus" \
|
|
||||||
PS1="\[\e[30;46m\] \h | \w \[\e[0;36m\]\[\e[m\] " \
|
PS1="\[\e[30;46m\] \h | \w \[\e[0;36m\]\[\e[m\] " \
|
||||||
TZ="Europe/Amsterdam"
|
TZ="Europe/Amsterdam"
|
||||||
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
export DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/bus
|
||||||
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" \
|
host-spawn -cwd "${PWD/#$HOME/$HOST_HOME}" \
|
||||||
$([ "$(basename "$0")" != "host" ] && echo "$(basename "$0")") "$@"
|
$([ "$(basename "$0")" != "host" ] && echo "$(basename "$0")") "$@"
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
FROM ghcr.io/job79/base:latest
|
ARG TAG
|
||||||
|
FROM git.plabble.org/job79/fedora:${TAG}
|
||||||
USER root
|
USER root
|
||||||
|
|
||||||
RUN dnf -y install go
|
RUN dnf -y install go
|
||||||
|
|
||||||
USER user
|
USER user
|
||||||
|
|||||||
2
containers/go/config.sh
Normal file
2
containers/go/config.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
arg "-v $HOME/Documents/go:/home/user/Documents/go"
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
FROM ghcr.io/job79/base:latest
|
ARG TAG
|
||||||
|
FROM git.plabble.org/job79/fedora:${TAG}
|
||||||
USER root
|
USER root
|
||||||
RUN dnf -y install kubectl
|
|
||||||
|
RUN dnf -y install kubectl openssl
|
||||||
|
RUN curl -sL https://talos.dev/install | sh
|
||||||
|
RUN curl -s https://fluxcd.io/install.sh | bash
|
||||||
|
|
||||||
USER user
|
USER user
|
||||||
|
|||||||
2
containers/infra/config.sh
Normal file
2
containers/infra/config.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
arg "-v $HOME/Documents/infra:/home/user/Documents/infra"
|
||||||
@@ -1 +0,0 @@
|
|||||||
FROM docker.io/kalilinux/kali-rolling
|
|
||||||
7
containers/vms/Containerfile
Normal file
7
containers/vms/Containerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
ARG TAG
|
||||||
|
FROM git.plabble.org/job79/fedora:${TAG}
|
||||||
|
USER root
|
||||||
|
|
||||||
|
RUN dnf -y install qemu-system-x86
|
||||||
|
|
||||||
|
USER user
|
||||||
6
containers/vms/config.sh
Normal file
6
containers/vms/config.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
arg "-v $HOME/Documents/vms:/home/user/Documents/vms"
|
||||||
|
arg "--net host"
|
||||||
|
arg "--device /dev/kvm"
|
||||||
|
arg "--device /dev/dri"
|
||||||
|
arg "--security-opt seccomp=unconfined"
|
||||||
98
devc.sh
98
devc.sh
@@ -4,12 +4,6 @@
|
|||||||
# Dev container enter script. Handles setting up #
|
# Dev container enter script. Handles setting up #
|
||||||
# different dev containers, resuming sessions and #
|
# different dev containers, resuming sessions and #
|
||||||
# automatic container updates. #
|
# automatic container updates. #
|
||||||
# #
|
|
||||||
# TODO: #
|
|
||||||
# - Remove security-opt label=disable #
|
|
||||||
# when possible. #
|
|
||||||
# - Look into removeing userns=keep-id. #
|
|
||||||
# - Isolate ssh keys to containers. #
|
|
||||||
# =============================================== #
|
# =============================================== #
|
||||||
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"; }
|
||||||
@@ -20,27 +14,32 @@ arg() { echo -n " $@"; }
|
|||||||
default_args() {
|
default_args() {
|
||||||
arg "--name $name"
|
arg "--name $name"
|
||||||
arg "--hostname $name"
|
arg "--hostname $name"
|
||||||
|
|
||||||
|
# Pull newer container image if available.
|
||||||
arg "--pull=newer"
|
arg "--pull=newer"
|
||||||
|
|
||||||
# Disable some security settings so host directories can
|
# Use keep-id so the container user matches the host user.
|
||||||
# be mounted without problems.
|
arg "--userns=keep-id"
|
||||||
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.
|
# 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
|
# Mount the wayland socket. Required to get the system
|
||||||
# clipboard (wl-copy) and gui applications working.
|
# 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"
|
[ -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.
|
# Mount the ssh socket to get ssh working.
|
||||||
[ -e "$SSH_AUTH_SOCK" ] && arg "-v $SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock"
|
[ -e "$SSH_AUTH_SOCK" ] && arg "-v $SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock"
|
||||||
|
|
||||||
# Load custom configuration for container.
|
# Make the user home dir a volume so it survives container
|
||||||
config_file="$script_dir/containers/$name/config.sh"
|
# restarts. Use copy to keep the files from the image.
|
||||||
[ -f "${config_file}" ] && source "${config_file}"
|
|
||||||
|
|
||||||
# Add a volume for the home directory so it survives
|
|
||||||
# container updates.
|
|
||||||
arg "-v $name:/home/user:copy"
|
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}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# param_args returns the podman run arguments based on the
|
# param_args returns the podman run arguments based on the
|
||||||
@@ -50,19 +49,50 @@ param_args() {
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
-gpu) # Enable gpu acceleration.
|
-gpu) # Enable gpu acceleration.
|
||||||
arg "--device /dev/dri" ;;
|
arg "--device /dev/dri" ;;
|
||||||
|
-kvm) # Enable KVM.
|
||||||
|
arg "--device /dev/kvm" ;;
|
||||||
|
-usb) # Enable USB access.
|
||||||
|
arg "--device /dev/bus/usb" ;;
|
||||||
-host-spawn) # Enable spawning host commands from inside the container using host-spawn.
|
-host-spawn) # Enable spawning host commands from inside the container using host-spawn.
|
||||||
arg "-v /run/user/$UID/bus:/tmp/bus" ;;
|
arg "-v /run/user/$UID/bus:/tmp/bus"
|
||||||
*) # Use argument as is.
|
arg "-e HOST_HOME=$HOME" # Used to translate paths.
|
||||||
echo "$1" ;;
|
;;
|
||||||
|
-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) # Mount directory.
|
||||||
|
shift
|
||||||
|
arg "-w /mnt/"
|
||||||
|
arg "-v $1:/mnt/$([ ! -d "$1" ] && echo 'file')"
|
||||||
|
;;
|
||||||
|
*) # Use unknown arguments a podman arguments.
|
||||||
|
arg "$1" ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
### MAIN ###
|
### MAIN ###
|
||||||
script_dir="$(dirname "$(realpath "$0")")"
|
# 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"
|
||||||
|
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%:*}"
|
||||||
|
|
||||||
# Get container registry from DEVC_REGISTRY env variable.
|
# Get container registry from the DEVC_REGISTRY env
|
||||||
|
# variable.
|
||||||
if [ -n "${DEVC_REGISTRY:-}" ]; then
|
if [ -n "${DEVC_REGISTRY:-}" ]; then
|
||||||
registry="$DEVC_REGISTRY"
|
registry="$DEVC_REGISTRY"
|
||||||
else
|
else
|
||||||
@@ -70,26 +100,18 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the devcontainer name from the first argument. If not
|
# Get container command from the DEVC_COMMAND env variable
|
||||||
# provided, use the last used name when possible.
|
# if set, else use bash -l.
|
||||||
if [[ $# -gt 0 ]] && [[ ${1:-} != -* ]]; then
|
if [ -z "${DEVC_COMMAND:-}" ]; then
|
||||||
name="$1"
|
DEVC_COMMAND="bash -l"
|
||||||
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
|
fi
|
||||||
|
|
||||||
# Create a new container when the container is not running or
|
# When container is not running or arguments are provided,
|
||||||
# when any arguments are provided.
|
# recreate it.
|
||||||
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ] || [[ $# -gt 0 ]]; then
|
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ] || [[ $# -gt 0 ]]; then
|
||||||
log "starting devcontainer..."
|
log "starting devcontainer..."
|
||||||
podman container rm -f -t 0 "$name" 1>/dev/null
|
podman container rm -f -t 0 "$name" 1>/dev/null
|
||||||
podman run -td $(default_args) $(param_args $@) "$registry/$name"
|
podman run -td $(default_args) $(param_args $@) "$registry/$image"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
podman exec -it "$name" bash -l
|
podman exec --detach-keys "ctrl-@" -it "$name" ${DEVC_COMMAND:-}
|
||||||
|
|||||||
Reference in New Issue
Block a user