Merge branch 'new-main'
Build containers / changes (push) Successful in 4s
Build containers / base-image (push) Failing after 5s

This commit is contained in:
maurice
2026-08-28 16:46:46 +02:00
22 changed files with 268 additions and 331 deletions
+54 -60
View File
@@ -13,10 +13,7 @@ jobs:
runs-on: job-v2 runs-on: job-v2
outputs: outputs:
any_change: ${{ steps.filter.outputs.workflow == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}} any_change: ${{ steps.filter.outputs.workflow == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
fedora: ${{ steps.filter.outputs.fedora == 'true' }} base: ${{ steps.filter.outputs.base == 'true' }}
go: ${{ steps.filter.outputs.go == 'true' }}
rust: ${{ steps.filter.outputs.rust == 'true' }}
dotnet: ${{ steps.filter.outputs.dotnet == 'true' }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: https://github.com/dorny/paths-filter@v3 - uses: https://github.com/dorny/paths-filter@v3
@@ -24,14 +21,11 @@ jobs:
with: with:
filters: | filters: |
workflow: ['.gitea/workflows/build.yaml'] workflow: ['.gitea/workflows/build.yaml']
fedora: ['containers/fedora/**'] base: ['containers/base/**']
go: ['containers/go/**']
rust: ['containers/rust/**']
dotnet: ['containers/dotnet/**']
base-image: base-image:
needs: [changes] needs: [changes]
if: ${{ needs.changes.outputs.fedora == 'true' || needs.changes.outputs.any_change == 'true' }} if: ${{ needs.changes.outputs.base == 'true' || needs.changes.outputs.any_change == 'true' }}
runs-on: job-v2 runs-on: job-v2
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -45,10 +39,10 @@ jobs:
id: build id: build
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
with: with:
image: maurice/fedora image: maurice/base
tags: ${{ github.ref_name }} tags: ${{ github.ref_name }}
context: ./containers/fedora context: ./containers/base
containerfiles: ./containers/fedora/Containerfile containerfiles: ./containers/base/Containerfile
- name: Push - name: Push
uses: redhat-actions/push-to-registry@v2 uses: redhat-actions/push-to-registry@v2
with: with:
@@ -61,51 +55,51 @@ jobs:
--compression-format=zstd --compression-format=zstd
--compression-level=12 --compression-level=12
dependent-images: # dependent-images:
needs: [changes, base-image] # needs: [changes, base-image]
if: always() && needs.changes.result == 'success' && (needs.base-image.result == 'success' || needs.base-image.result == 'skipped') # if: always() && needs.changes.result == 'success' && (needs.base-image.result == 'success' || needs.base-image.result == 'skipped')
runs-on: job-v2 # runs-on: job-v2
strategy: # strategy:
fail-fast: false # fail-fast: false
matrix: # matrix:
container: [rust, dotnet, go] # container: [rust, dotnet, go]
steps: # steps:
- name: Check if build needed # - name: Check if build needed
id: check # id: check
run: | # run: |
if [[ "${{ matrix.container }}" == "go" && "${{ needs.changes.outputs.go }}" == "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 }}" == "rust" && "${{ needs.changes.outputs.rust }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi # if [[ "${{ matrix.container }}" == "rust" && "${{ needs.changes.outputs.rust }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
if [[ "${{ matrix.container }}" == "dotnet" && "${{ needs.changes.outputs.dotnet }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi # if [[ "${{ matrix.container }}" == "dotnet" && "${{ needs.changes.outputs.dotnet }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
if [[ "${{ needs.changes.outputs.any_change }}" == "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 # - name: Clone repo
if: steps.check.outputs.run == 'true' # if: steps.check.outputs.run == 'true'
uses: actions/checkout@v4 # uses: actions/checkout@v4
- name: Log in # - name: Log in
if: steps.check.outputs.run == 'true' # if: steps.check.outputs.run == 'true'
uses: redhat-actions/podman-login@v1 # uses: redhat-actions/podman-login@v1
with: # with:
registry: git.plabble.org # registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }} # username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }} # password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build # - name: Build
id: build # id: build
if: steps.check.outputs.run == 'true' # if: steps.check.outputs.run == 'true'
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef # uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
with: # with:
image: maurice/${{ matrix.container }} # image: maurice/${{ matrix.container }}
tags: ${{ github.ref_name }} # tags: ${{ github.ref_name }}
context: ./containers/${{ matrix.container }} # context: ./containers/${{ matrix.container }}
containerfiles: ./containers/${{ matrix.container }}/Containerfile # containerfiles: ./containers/${{ matrix.container }}/Containerfile
build-args: TAG=${{ github.ref_name }} # build-args: TAG=${{ github.ref_name }}
- name: Push # - name: Push
if: steps.check.outputs.run == 'true' # if: steps.check.outputs.run == 'true'
uses: redhat-actions/push-to-registry@v2 # uses: redhat-actions/push-to-registry@v2
with: # with:
image: ${{ steps.build.outputs.image }} # image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }} # tags: ${{ steps.build.outputs.tags }}
registry: git.plabble.org # registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }} # username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }} # password: ${{ secrets.REGISTRY_TOKEN }}
extra-args: | # extra-args: |
--compression-format=zstd # --compression-format=zstd
--compression-level=12 # --compression-level=12
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
cd container && \
podman build -t git.plabble.org/maurice/devc:main .
+107
View File
@@ -0,0 +1,107 @@
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 curl awk jq rg zip unzip which \
host-spawn wl-copy gcc helix helix-themes rsync python3 python3-pip dotnet-sdk-10.0 openssl-devel
# === 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
# === Add host entry for podman & XDG open ===
RUN ln -s /usr/local/bin/host /usr/local/bin/podman && \
ln -s /usr/local/bin/host /usr/local/bin/xdg-open
COPY config/bin /usr/local/bin
# === languages & SDKs ===
# Golang
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 && \
export GOPATH=/usr/local/go && \
go install golang.org/x/tools/gopls@latest && \
ln -sf /usr/local/go/bin/gopls /usr/local/bin/gopls
# Deno
RUN export DENO_INSTALL=/usr/local/deno && \
curl -fsSL https://deno.land/install.sh | sh && \
ln -sf /usr/local/deno/bin/deno /usr/local/bin/deno
# Rust
RUN export RUSTUP_HOME=/usr/local/rust && \
export CARGO_HOME=/usr/local/rust && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path && \
ln -sf /usr/local/rust/bin/rustc /usr/local/bin/rustc && \
ln -sf /usr/local/rust/bin/cargo /usr/local/bin/cargo && \
ln -sf /usr/local/rust/bin/rustup /usr/local/bin/rustup && \
ln -sf /usr/local/rust/bin/rustfmt /usr/local/bin/rustfmt && \
ln -sf /usr/local/rust/bin/clippy /usr/local/bin/clippy && \
ln -sf /usr/local/rust/bin/rust-analyzer /usr/local/bin/rust-analyzer && \
rustup component add rustfmt clippy rust-analyzer && \
curl https://drager.github.io/wasm-pack/installer/init.sh -sSf | sh
# cargo install cargo-generate && \
# cargo install cargo-expand
# Dotnet
RUN dotnet tool install --global dotnet-ef && \
mkdir -p /usr/local/bin/omnisharp && \
curl -L https://github.com/OmniSharp/omnisharp-roslyn/releases/latest/download/omnisharp-linux-x64-net6.0.tar.gz \
| tar xz -C /usr/local/bin/omnisharp && \
chmod +x /usr/local/bin/omnisharp/OmniSharp
# PHP
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y install https://rpm.henderkes.com/static-php-1-0.noarch.rpm && \
dnf -y module enable php-zts:static-8.5 && \
dnf install -y \
frankenphp \
php-zts-dom \
php-zts-xml \
php-zts-tokenizer \
php-zts-session \
php-zts-posix \
php-zts-fileinfo \
php-zts-simplexml \
php-zts-xmlreader \
php-zts-xmlwriter \
php-zts-soap \
php-zts-gd \
php-zts-pdo_mysql \
php-zts-pcntl \
php-zts-zip \
php-zts-exif \
php-zts-bcmath \
php-zts-mysqli \
php-zts-imagick \
php-zts-grpc && \
curl -fsSL https://getcomposer.org/installer | \
php -- --install-dir=/usr/local/bin --filename=composer
# === install language servers, tools ===
RUN deno i -g -f -A --root /usr/local/bin npm:npm npm:bash-language-server npm:vscode-langservers-extracted npm:dockerfile-language-server-nodejs \
npm:typescript npm:typescript-language-server
USER user
WORKDIR /home/user
RUN mkdir -p .config .local .cache
COPY --chown=user:user config/bashrc .bashrc
COPY --chown=user:user config/git .config/git/config
COPY --chown=user:user config/helix/ .config/helix/
# === Cleanup build dependencies ===
USER root
RUN dnf remove -y openssl-devel && dnf clean all && \
rm -rf /tmp/* && rm -rf /root/*
USER user
VOLUME /home/user
@@ -5,6 +5,9 @@ export EDITOR=hx \
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 \
CARGO_HOME=/usr/local/rust \
RUSTUP_HOME=/usr/local/rust \
GOPATH=/usr/local/go \
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" \
SHELL="/bin/bash" SHELL="/bin/bash"
@@ -13,7 +16,7 @@ export EDITOR=hx \
pbcopy() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; } pbcopy() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
alias random="cat /dev/urandom | tr -dc '[:alpha:]' | fold -w ${1:-20} | head -n 1" alias random="cat /dev/urandom | tr -dc '[:alpha:]' | fold -w ${1:-20} | head -n 1"
# Git aliases # === Git aliases ===
alias gc="git commit -m" alias gc="git commit -m"
alias ga="git add -A" alias ga="git add -A"
alias gf="git fetch" alias gf="git fetch"
+6
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"} "$@
+33
View File
@@ -0,0 +1,33 @@
# C#
[language-server.omnisharp]
command = "/usr/local/bin/omnisharp/OmniSharp"
args = [ "--languageserver" ]
# Rust
[language-server.rust-analyzer.config.check]
command = "clippy"
[language-server.deno-lsp]
command = "deno"
args = ["lsp"]
config.deno.enable = true
[[language]]
name = "rust"
formatter = { command = "rustfmt" }
# TS
[[language]]
name = "typescript"
roots = ["deno.json", "deno.jsonc", "package.json"]
file-types = ["ts", "tsx"]
auto-format = true
language-servers = ["deno-lsp"]
# JS
[[language]]
name = "javascript"
roots = ["deno.json", "deno.jsonc", "package.json"]
file-types = ["js", "jsx"]
auto-format = true
language-servers = ["deno-lsp"]
-20
View File
@@ -1,20 +0,0 @@
FROM git.plabble.org/maurice/dotnet:main
ARG studio_version="2025.1.4.8"
ARG download_uri="https://redirector.gvt1.com/edgedl/android/studio/ide-zips/${studio_version}/android-studio-${studio_version}-linux.tar.gz"
USER root
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y --setopt=keepcache=1 install libXext libXrender libXtst libX11 freetype freetype-devel mesa-libGLU
USER user
RUN curl -Lo /tmp/studio.tar.gz "${download_uri}" && \
mkdir /home/user/AndroidStudio && \
mkdir /home/user/Android && \
tar -zxf /tmp/studio.tar.gz -C /home/user/AndroidStudio && \
rm /tmp/studio.tar.gz && \
mv /home/user/AndroidStudio/android-studio*/* /home/user/AndroidStudio
RUN echo 'alias studio="$HOME/AndroidStudio/bin/studio"' >> /home/user/.bashrc
RUN echo 'export ANDROID_HOME="$HOME/Android/Sdk"' >> /home/user/.bashrc
RUN echo 'export PATH="$ANDROID_HOME/platform-tools:$PATH"' >> /home/user/.bashrc
-11
View File
@@ -1,11 +0,0 @@
FROM git.plabble.org/maurice/fedora:main
USER root
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y --setopt=keepcache=1 install dotnet-sdk-9.0 dotnet-sdk-10.0
COPY install-roslyn.sh /tmp/install-roslyn.sh
RUN chmod +x /tmp/install-roslyn.sh && /tmp/install-roslyn.sh
USER user
RUN dotnet tool install --global dotnet-ef
-9
View File
@@ -1,9 +0,0 @@
#!/bin/bash
version="v1.39.15"
arch="linux-x64"
link="https://github.com/OmniSharp/omnisharp-roslyn/releases/download/$version/omnisharp-$arch-net6.0.tar.gz"
curl -Lo /tmp/omnisharp.tar.gz $link
mkdir /home/user/.omnisharp
tar -zxf /tmp/omnisharp.tar.gz -C /home/user/.omnisharp/
chown -R user:user /home/user/.omnisharp
-31
View File
@@ -1,31 +0,0 @@
FROM quay.io/fedora/fedora:43
# === install system packages ===
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf update -y && \
dnf -y --setopt=keepcache=1 install procps ping bash-completion glibc-langpack-en \
host-spawn dbus-launch \
git pnpm helix zip rsync
# === 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
# === Add host entry for podman ===
RUN ln -s /usr/local/bin/host /usr/local/bin/podman
USER user
WORKDIR /home/user
RUN mkdir .config .local .cache
COPY --chown=user:user config/bashrc .bashrc
COPY --chown=user:user config/git .config/git/config
COPY --chown=user:user config/helix/ .config/helix/
COPY config/bin /usr/local/bin
# === Setup PNPM & install language servers ===
RUN /bin/bash -c "SHELL=/bin/bash pnpm setup && . /home/user/.bashrc && pnpm i -g deno bash-language-server vscode-langservers-extracted dockerfile-language-server-nodejs \
typescript typescript-language-server"
VOLUME /home/user
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
arg "-p 5173:5173 --network dev-php"
-4
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")") "$@"
@@ -1,12 +0,0 @@
# C#
[language-server.omnisharp]
command = "/home/user/.omnisharp/OmniSharp"
args = [ "--languageserver" ]
# Rust
[language-server.rust-analyzer.config.check]
command = "clippy"
[[language]]
name = "rust"
formatter = { command = "rustfmt" }
-11
View File
@@ -1,11 +0,0 @@
FROM git.plabble.org/maurice/android:main
ARG flutter_version="3.35.7-stable"
ARG download_uri="https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${flutter_version}.tar.xz"
RUN mkdir /home/user/Flutter && \
curl -Lo /tmp/flutter.tar.xz "${download_uri}" && \
tar -xf /tmp/flutter.tar.xz -C /home/user/Flutter && \
rm /tmp/flutter.tar.xz
RUN echo 'export PATH="$HOME/Flutter/flutter/bin:$PATH"' >> /home/user/.bashrc
RUN echo 'export FLUTTER_ROOT="$HOME/Flutter/flutter"' >> /home/user/.bashrc
-7
View File
@@ -1,7 +0,0 @@
FROM git.plabble.org/maurice/fedora:main
USER root
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y --setopt=keepcache=1 install go
USER user
-16
View File
@@ -1,16 +0,0 @@
FROM git.plabble.org/maurice/dotnet:main
ARG rider_version="2025.3.2"
ARG download_uri="https://download.jetbrains.com/rider/JetBrains.Rider-${rider_version}.tar.gz"
USER root
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
dnf -y --setopt=keepcache=1 install libXext libXrender libXtst libX11 freetype freetype-devel
USER user
RUN curl -Lo /tmp/rider.tar.gz "${download_uri}" && \
mkdir /home/user/Rider && \
tar -zxf /tmp/rider.tar.gz -C /home/user/Rider && \
rm /tmp/rider.tar.gz && \
mv /home/user/Rider/JetBrains*/* /home/user/Rider
RUN echo 'alias rider="$HOME/Rider/bin/rider"' >> /home/user/.bashrc
-4
View File
@@ -1,4 +0,0 @@
#!/bin/bash
#arg "-p 8080:8080"
#arg "-p 8081:8081"
arg "--network scripts_dev-php"
-12
View File
@@ -1,12 +0,0 @@
FROM git.plabble.org/maurice/fedora:main
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN . '/home/user/.cargo/env' && rustup component add rust-analyzer
# Raspberry Pi Pico tools
RUN sudo dnf install -y \
systemd-devel \
pkg-config \
&& dnf clean all
RUN . "$HOME/.cargo/env" && cargo install elf2uf2-rs --locked
RUN . "$HOME/.cargo/env" && rustup target add thumbv6m-none-eabi
+58 -100
View File
@@ -1,124 +1,82 @@
#!/bin/bash #!/bin/bash
# =============================================== # # =============================================== #
# devc.sh v2.0; job79, maurice # # devc.sh v2.1; job79, maurice #
# Dev container enter script. Handles setting up # # Dev container entry script. #
# different dev containers, resuming sessions and #
# automatic container updates. #
# =============================================== # # =============================================== #
set -eu set -euo pipefail
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-}" "$1"; } log() { echo -e "\e[36m○\e[0m $1"; }
arg() { echo -n " $@"; } die() { echo -e "\e[31mx\e[0m $1" && exit 1; }
# run_args returns the podman run arguments required for # default_args configures standard container options.
# starting a new container.
default_args() { default_args() {
arg "--name $name" run_opts+=(
arg "--hostname $name" "--name" "$name"
"--hostname" "$name"
"--network" "devc"
"--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.
)
# Pull newer container image if available. # Unix sockets require SELinux label disable.
arg "--pull=newer" [[ -d /sys/fs/selinux ]] && run_opts+=("--security-opt" "label=disable")
# Use keep-id so the container user matches the host user. # Desktop integration (Wayland, SSH).
arg "--userns=keep-id" [[ -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 # Load custom container config.
# without problems. local config_file="${BASH_SOURCE[0]%/*}/container/config.sh"
arg "--security-opt label=disable" [[ -f "$config_file" ]] && source "$config_file" || true
# 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}"
} }
# param_args returns the podman run arguments based on the # param_args parses CLI arguments into podman run options.
# arguments provided to this script.
param_args() { param_args() {
while test $# -gt 0; do while (($# > 0)); do
case "$1" in case "$1" in
-gpu) # Enable gpu acceleration. -gpu) run_opts+=("--device" "/dev/dri") ;;
arg "--device /dev/dri" ;; -kvm) run_opts+=("--device" "/dev/kvm") ;;
-kvm) # Enable KVM -usb) run_opts+=("--device" "/dev/bus/usb") ;;
arg "--device /dev/kvm" ;; -host-spawn) run_opts+=("-v" "/run/user/$UID/bus:/tmp/bus" "-e" "HOST_HOME=$HOME") ;;
-usb) # Enable USB access -container-sock) run_opts+=("-v" "$XDG_RUNTIME_DIR/podman/podman.sock:/var/run/docker.sock") ;;
arg "--device /dev/bus/usb" ;; -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") ;;
-host-spawn) # Enable spawning host commands from inside the container using host-spawn. -mnt) shift && run_opts+=("-w" "/mnt/" "-v" "$1:/mnt/$([[ -d "$1" ]] || echo "file")") ;;
arg "-v /run/user/$UID/bus:/tmp/bus" *) run_opts+=("$1") ;;
arg "-e HOST_HOME=$HOME" # Used to translate paths.
;;
-net) # Enable network dev-<container name>
arg "--network dev-$name"
;;
-mnt) # Mount directory.
shift
arg "-w /workdir/"
arg "-v $1:/workdir/$([ ! -d "$1" ] && echo $1)"
;;
-mdf) # Mount dev folder
arg "-v $HOME/dev:/home/user/dev"
;;
-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"
;;
*) # Use unknown arguments a podman arguments.
arg "$1" ;;
esac esac
shift shift
done done
} }
### MAIN ### main() {
# Get the devcontainer name from the first argument. If not local state_file="$HOME/.local/share/devc-previous-container"
# provided, use the last used name when possible. local image="devc"
if [[ $# -gt 0 ]] && [[ ${1:-} != -* ]]; then
image="$1" # Resolve container name (CLI arg > Last used > Error).
[[ "$image" != *:* ]] && image="$image:main" if [[ $image && $image != -* ]]; then
echo "$image" >"$HOME/.local/share/devc-previous-container"
shift shift
elif [ -f "$HOME/.local/share/devc-previous-container" ]; then [[ $image != *:* ]] && image+=":main"
image=$(<"$HOME/.local/share/devc-previous-container") echo "$image" >"$state_file"
elif [[ -f $state_file ]]; then
image=$(<$state_file)
else else
log "no container name specified" 'x' 31 die "no container name specified"
exit 1
fi fi
name="${image%:*}" local name="${image%:*}"
# Get container registry from the DEVC_REGISTRY env # Start/Restart if not running or if arguments change configuration.
# variable. if [[ -z "$(podman ps -q -f name="^$name$" -f status=running)" ]] || (($# > 0)); then
if [ -n "${DEVC_REGISTRY:-}" ]; then log "starting $image..."
registry="$DEVC_REGISTRY"
else default_args
log "registry unknown; set the DEVC_REGISTRY environment variable" 'x' 31 param_args "$@"
exit 1
[[ -n "${DEVC_REGISTRY:-}" ]] || die "registry unknown; set the DEVC_REGISTRY environment variable"
podman network create devc --ignore > /dev/null 2>&1
podman run --replace --stop-timeout 0 -td "${run_opts[@]}" "$DEVC_REGISTRY/$image"
fi fi
# Get container command from the DEVC_COMMAND env variable exec podman exec --detach-keys "ctrl-@,ctrl-@" -it "$name" ${DEVC_COMMAND:-bash -l}
# if set, else use bash -l. }
if [ -z "${DEVC_COMMAND:-}" ]; then
DEVC_COMMAND="bash -l"
fi
# When container is not running or arguments are provided, main "$@"
# recreate it.
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ] || [[ $# -gt 0 ]]; then
log "starting devcontainer..."
podman network create --ignore "dev-$name"
podman container rm -f -t 0 "$name" 1>/dev/null
podman run -td $(default_args) $(param_args $@) "$registry/$image"
fi
podman exec --detach-keys "ctrl-@" -it "$name" ${DEVC_COMMAND:-}
-28
View File
@@ -1,28 +0,0 @@
# Tools
pbcopy() { curl -sF "content=<-" "https://paste.plabble.org/$2?lang=$1" && echo; }
alias code="flatpak run com.visualstudio.code"
alias random="cat /dev/urandom | tr -dc '[:alpha:]' | fold -w ${1:-20} | head -n 1"
# Dev containers
export DEVC_REGISTRY="git.plabble.org/maurice"
function devc() {
"$HOME/dev/devcontainer/devc.sh" "$@" -mdf
}
alias rider="DEVC_COMMAND=/home/user/Rider/bin/rider devc rider -x11 -host-spawn -net"
alias flutter="devc flutter -x11 -host-spawn -kvm -usb -gpu"
alias androidstudio="DEVC_COMMAND=/home/user/AndroidStudio/bin/studio devc android -x11 -host-spawn -kvm -usb -gpu"
function hx() {
arg="${1:-.}"
DEVC_COMMAND="hx $arg" devc fedora -mnt $arg
}
# Git aliases
alias gc="git commit -m"
alias ga="git add -A"
alias gf="git fetch"
alias gp="git pull"
alias gpp="git push"
alias gs="git status"