Compare commits

..

15 Commits

Author SHA1 Message Date
Job79 53cfeb1a62 feat: update container on build
Container build / container-build (push) Successful in 3m21s
2024-09-29 11:31:49 +02:00
Job79 562b26b96a ci: build the container weekly 2024-09-29 11:31:47 +02:00
Job79 7465b394f4 feat: keep cache in a volume 2024-09-29 11:29:40 +02:00
Job79 2e49a4f3a3 feat: move to gitea container
Container build / container-build (push) Successful in 2m56s
2024-09-28 20:09:34 +02:00
Job79 755605b2fb fix: move copilot credentials to volume
Container build / container-build (push) Successful in 2m33s
2024-09-28 20:05:30 +02:00
Job79 5c7db03b32 ci: attempt to get cache working
Container build / container-build (push) Has been cancelled
2024-09-28 19:59:48 +02:00
Job79 8c13f219b5 fix: attempt to fix ci errors
Container build / container-build (push) Successful in 3m10s
2024-09-28 19:30:29 +02:00
Job79 6556db0ce6 ci: update docker/build-push-action to v6
Container build / container-build (push) Failing after 1m1s
2024-09-28 19:17:56 +02:00
Job79 0e51472973 ci: add container build
Container build / container-build (push) Successful in 3m56s
2024-09-28 18:01:04 +02:00
Job79 54865b536a feat: make container updates easier 2024-09-28 17:56:33 +02:00
Job79 7a63471603 chore: switch to rosepine themed PS1 2024-09-24 19:24:59 +02:00
Job79 9a20313beb feat: update config 2024-09-24 19:24:17 +02:00
Job79 5e3d7ca7fb feat: switch to lazyvim 2024-09-23 19:56:52 +02:00
Job79 17e3a6840f feat: switch to neovim 2024-09-17 18:32:24 +00:00
Job79 c510c7f919 init 2024-03-30 20:41:55 +01:00
23 changed files with 117 additions and 302 deletions
-115
View File
@@ -1,115 +0,0 @@
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')
runs-on: job-v2
strategy:
fail-fast: false
matrix:
container: [infra, go, php]
steps:
- name: Check if build needed
id: check
run: |
if [[ "${{ matrix.container }}" == "infra" && "${{ needs.changes.outputs.infra }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
if [[ "${{ matrix.container }}" == "go" && "${{ needs.changes.outputs.go }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
if [[ "${{ matrix.container }}" == "php" && "${{ needs.changes.outputs.php }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
if [[ "${{ needs.changes.outputs.any_change }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
- 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
+32
View File
@@ -0,0 +1,32 @@
name: Container build
on:
push:
schedule:
- cron: '0 16 * * FRI'
jobs:
container-build:
runs-on: ubuntu-latest
if: gitea.ref == 'refs/heads/main'
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Set up BuildX
uses: docker/setup-buildx-action@v2
with:
endpoint: 'unix:///var/run/docker.sock'
- 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
uses: docker/build-push-action@v6
with:
context: .
file: ./Containerfile
push: true
tags: git.plabble.org/job79/dev:latest
+23
View File
@@ -0,0 +1,23 @@
FROM docker.io/fedora:41
# === setup system ===
RUN dnf update -y && dnf -y install neovim unzip \
bash-completion zoxide fd-find procps \
git go npm
# === setup container user ===
RUN useradd -ms /bin/bash user && usermod -aG wheel user && sed -i '/NOPASSWD/s/^#//g' /etc/sudoers
USER user
WORKDIR /home/user
COPY config/user/bashrc /home/user/.bashrc
# === setup neovim ===
RUN git clone --depth 1 https://github.com/LazyVim/starter ~/.config/nvim
COPY config/nvim/plugins /home/user/.config/nvim/lua/plugins
COPY config/nvim/config/options.lua /home/user/.config/nvim/lua/config/options.lua
COPY config/nvim/lazyvim.json /home/user/.config/nvim/lazyvim.json
# === setup container ===
ENV TZ="Europe/Amsterdam"
VOLUME /home/user/.local /home/user/.cache /home/user/.config/github-copilot
CMD ["bash"]
Executable
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
podman build . -t dev
+1
View File
@@ -0,0 +1 @@
vim.o.relativenumber = false
+10
View File
@@ -0,0 +1,10 @@
{
"extras": [
"lazyvim.plugins.extras.coding.copilot",
"lazyvim.plugins.extras.dap.core"
],
"news": {
"NEWS.md": "6520"
},
"version": 6
}
+9
View File
@@ -0,0 +1,9 @@
return {
{ "rose-pine/neovim", name = "rose-pine" },
{
"LazyVim/LazyVim",
opts = {
colorscheme = "rose-pine-dawn",
},
},
}
+10
View File
@@ -0,0 +1,10 @@
return {
{
"nvimdev/dashboard-nvim",
enabled = false,
},
{
"bufferline.nvim",
enabled = false,
},
}
+13
View File
@@ -0,0 +1,13 @@
. /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\] container | \w \[\e[0;36m\]\[\e[m\] '
# === aliases and functions ===
alias vi=nvim
post() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
eval "$(zoxide init --cmd cd bash)"
-32
View File
@@ -1,32 +0,0 @@
FROM quay.io/fedora/fedora:44
# === install system packages ===
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf update -y && \
dnf -y --setopt=keepcache=1 --setopt=install_weak_deps=False install \
bash-completion git-core fzf curl awk jq fd-find rg unzip which \
host-spawn wl-copy gcc
RUN LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | jq -r .tag_name | sed 's/^v//') && \
curl -sL "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_linux_x86_64.tar.gz" | tar xz -C /usr/local/bin lazygit && \
curl -sL "https://github.com/jorgerojas26/lazysql/releases/latest/download/lazysql_Linux_x86_64.tar.gz" | tar xz -C /usr/local/bin lazysql && \
curl -sL "https://github.com/neovim/neovim/releases/download/nightly/nvim-linux-x86_64.tar.gz" | tar xz -C /usr/local --strip-components=1
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
-21
View File
@@ -1,21 +0,0 @@
source /etc/bashrc
# === bash settings ===
set -o vi
bind -m vi-insert '"\C-l": clear-screen'
# === environment ===
export PS1="\[\e[30;46m\] \h | \w \[\e[0;36m\]\[\e[m\] " \
EDITOR="nvim" \
WAYLAND_DISPLAY="wayland-0" \
XDG_RUNTIME_DIR="/run/user/1000" \
SSH_AUTH_SOCK="/run/user/1000/ssh-auth-sock" \
TZ="Europe/Amsterdam" \
FZF_CTRL_T_COMMAND="fd --type f --hidden --exclude .git --exclude Library --exclude .cache" \
FZF_ALT_C_COMMAND="fd --type d --hidden --exclude .git --exclude Library --exclude .cache"
# === aliases and functions ===
alias vi=nvim
post() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
eval "$(fzf --bash)"
-6
View File
@@ -1,6 +0,0 @@
#!/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"} "$@"
-1
View File
@@ -1 +0,0 @@
host
-1
View File
@@ -1 +0,0 @@
host
-12
View File
@@ -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
-10
View File
@@ -1,10 +0,0 @@
ARG TAG
FROM job79/base:${TAG}
USER root
RUN GO_VERSION=$(curl -sL "https://go.dev/VERSION?m=text" | head -n 1 | tr -d '\r\n') && \
curl -sL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" | tar xz -C /usr/local && \
ln -sf /usr/local/go/bin/go /usr/local/bin/go && \
ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt
USER user
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
run_opts+=("-v" "$HOME/Documents/go:/home/user/Documents/go")
-11
View File
@@ -1,11 +0,0 @@
ARG TAG
FROM job79/base:${TAG}
USER root
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y --setopt=keepcache=1 --setopt=install_weak_deps=False install \
just 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
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
run_opts+=("-v" "$HOME/Documents/infra:/home/user/Documents/infra")
-9
View File
@@ -1,9 +0,0 @@
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 npm && \
composer global require laravel/installer
USER user
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
run_opts+=("-v" "$HOME/Documents/php:/home/user/Documents/php")
-78
View File
@@ -1,78 +0,0 @@
#!/bin/bash
# =============================================== #
# devc.sh v2.1; job79, maurice #
# Dev container entry script. #
# =============================================== #
set -euo pipefail
log() { echo -e "\e[36m○\e[0m $1"; }
die() { echo -e "\e[31mx\e[0m $1" && exit 1; }
# default_args configures standard container options.
default_args() {
run_opts+=(
"--name" "$name"
"--hostname" "$name"
"--pull=newer" # Update image.
"--userns=keep-id" # Map host user.
"-v" "$name:/home/user:copy" # Persistent home volume.
"-v" "dnf-cache:/var/cache/libdnf5" # Cache dnf metadata.
)
# Unix sockets require SELinux label disable.
[[ -d /sys/fs/selinux ]] && run_opts+=("--security-opt" "label=disable")
# 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")
# Load custom container config.
local config_file="${BASH_SOURCE[0]%/*}/containers/$name/config.sh"
[[ -f "$config_file" ]] && source "$config_file" || true
}
# param_args parses CLI arguments into podman run options.
param_args() {
while (($# > 0)); do
case "$1" in
-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/podman/podman.sock:/var/run/docker.sock") ;;
-x11) run_opts+=("-v" "/tmp/.X11-unix:/tmp/.X11-unix" "-v" "$XAUTHORITY:/run/user/1000/.Xauthority:ro" "-e" "DISPLAY=$DISPLAY" "-e" "XAUTHORITY=/run/user/1000/.Xauthority") ;;
-mnt) shift && run_opts+=("-w" "/mnt/" "-v" "$1:/mnt/$([[ -d "$1" ]] || echo "file")") ;;
*) run_opts+=("$1") ;;
esac
shift
done
}
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
[[ $image != *:* ]] && image+=":main"
echo "$image" >"$state_file"
elif [[ -f $state_file ]]; then
image=$(<$state_file)
else
die "no container name specified"
fi
local name="${image%:*}"
# 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..."
default_args
param_args "$@"
[[ -n "${DEVC_REGISTRY:-}" ]] || die "registry unknown; set the DEVC_REGISTRY environment variable"
podman run --replace --stop-timeout 0 -td "${run_opts[@]}" "$DEVC_REGISTRY/$image"
fi
exec podman exec --detach-keys "ctrl-@,ctrl-@" -it "$name" ${DEVC_COMMAND:-bash -l}
}
main "$@"
Executable
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
name="${1:-dev}"
podman container rm -f -t 1 "$name"
podman pull git.plabble.org/job79/dev:latest
podman run -it \
--name "$name" \
-v /run/user/1000/wayland-0:/run/user/1000/wayland-0 \
-v "$SSH_AUTH_SOCK":/run/user/1000/ssh-auth-sock \
-v ~/Documents:/home/user/Documents \
-v ~/.ssh:/home/user/.ssh \
-v ~/.config/git:/home/user/.config/git \
-v "$name"-copilot:/home/user/.config/github-copilot \
-v "$name"-local:/home/user/.local \
-v "$name"-cache:/home/user/.cache \
--security-opt label=disable \
--userns=keep-id \
git.plabble.org/job79/dev:latest