Big boom
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd containers/base
|
cd container && \
|
||||||
podman build -t git.plabble.org/maurice/base:main .
|
podman build -t git.plabble.org/maurice/devc:main .
|
||||||
cd ../rider
|
|
||||||
podman build -t git.plabble.org/maurice/rider:main .
|
|
||||||
@@ -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"
|
||||||
Executable
+6
@@ -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"} "$@
|
||||||
@@ -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"]
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
FROM git.plabble.org/maurice/base:main
|
|
||||||
ARG studio_version="2025.3.2.6"
|
|
||||||
ARG download_uri="https://redirector.gvt1.com/edgedl/android/studio/ide-zips/${studio_version}/android-studio-${studio_version}-linux.tar.gz"
|
|
||||||
|
|
||||||
USER root
|
|
||||||
# === setup GUI ===
|
|
||||||
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
|
|
||||||
@@ -1,53 +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 openssl-devel \
|
|
||||||
host-spawn dbus-launch \
|
|
||||||
git pnpm helix zip rsync \
|
|
||||||
dotnet-sdk-10.0
|
|
||||||
|
|
||||||
# === 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
|
|
||||||
|
|
||||||
# === root language servers ===
|
|
||||||
COPY install-roslyn.sh /tmp/install-roslyn.sh
|
|
||||||
RUN chmod +x /tmp/install-roslyn.sh && /tmp/install-roslyn.sh && rm /tmp/omnisharp.tar.gz && rm /tmp/install-roslyn.sh
|
|
||||||
# RUN go install golang.org/x/tools/gopls@latest
|
|
||||||
|
|
||||||
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, tools ===
|
|
||||||
RUN /bin/bash -c ". /home/user/.bashrc && pnpm setup && . /home/user/.bashrc && pnpm i -g deno bash-language-server vscode-langservers-extracted dockerfile-language-server-nodejs \
|
|
||||||
typescript typescript-language-server"
|
|
||||||
|
|
||||||
RUN dotnet tool install --global dotnet-ef && \
|
|
||||||
echo 'export PATH="$PATH:/home/user/.dotnet/tools:/home/user/.cargo/env"' >> /home/user/.bashrc
|
|
||||||
|
|
||||||
# === Rust, WASM toolchain ===
|
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
||||||
RUN . /home/user/.bashrc && rustup component add rust-analyzer && \
|
|
||||||
curl https://drager.github.io/wasm-pack/installer/init.sh -sSf | sh && \
|
|
||||||
cargo install cargo-generate && \
|
|
||||||
cargo install cargo-expand
|
|
||||||
|
|
||||||
# === Cleanup build dependencies ===
|
|
||||||
USER root
|
|
||||||
RUN dnf remove -y openssl-devel && dnf clean all && rm -rf /home/user/.cargo
|
|
||||||
USER user
|
|
||||||
|
|
||||||
VOLUME /home/user
|
|
||||||
@@ -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" }
|
|
||||||
@@ -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
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
FROM git.plabble.org/maurice/base:main
|
|
||||||
ARG flutter_version="3.41.4-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
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM git.plabble.org/maurice/base:main
|
|
||||||
ARG rider_version="2025.3.3"
|
|
||||||
ARG download_uri="https://download.jetbrains.com/rider/JetBrains.Rider-${rider_version}.tar.gz"
|
|
||||||
|
|
||||||
USER root
|
|
||||||
|
|
||||||
# === setup GUI ===
|
|
||||||
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
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
mkdir -p /tmp/joypet-sockets
|
|
||||||
arg "-p 7777:7777"
|
|
||||||
arg "-v /tmp/joypet-sockets:/var/run/joypet-sockets:Z"
|
|
||||||
@@ -1,125 +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>'' and 'devc'
|
|
||||||
arg "--network dev-$name --network devc"
|
|
||||||
;;
|
|
||||||
-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"
|
|
||||||
[[ "$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 the DEVC_REGISTRY env
|
# Resolve container name (CLI arg > Last used > Error).
|
||||||
# variable.
|
if [[ $image && $image != -* ]]; then
|
||||||
if [ -n "${DEVC_REGISTRY:-}" ]; then
|
shift
|
||||||
registry="$DEVC_REGISTRY"
|
[[ $image != *:* ]] && image+=":main"
|
||||||
else
|
echo "$image" >"$state_file"
|
||||||
log "registry unknown; set the DEVC_REGISTRY environment variable" 'x' 31
|
elif [[ -f $state_file ]]; then
|
||||||
exit 1
|
image=$(<$state_file)
|
||||||
fi
|
else
|
||||||
|
die "no container name specified"
|
||||||
|
fi
|
||||||
|
local name="${image%:*}"
|
||||||
|
|
||||||
# Get container command from the DEVC_COMMAND env variable
|
# Start/Restart if not running or if arguments change configuration.
|
||||||
# if set, else use bash -l.
|
if [[ -z "$(podman ps -q -f name="^$name$" -f status=running)" ]] || (($# > 0)); then
|
||||||
if [ -z "${DEVC_COMMAND:-}" ]; then
|
log "starting $image..."
|
||||||
DEVC_COMMAND="bash -l"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# When container is not running or arguments are provided,
|
default_args
|
||||||
# recreate it.
|
param_args "$@"
|
||||||
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ] || [[ $# -gt 0 ]]; then
|
|
||||||
log "starting devcontainer..."
|
|
||||||
podman network create --ignore "dev-$name"
|
|
||||||
podman network create --ignore "devc"
|
|
||||||
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:-}
|
[[ -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
|
||||||
|
|
||||||
|
exec podman exec --detach-keys "ctrl-@,ctrl-@" -it "$name" ${DEVC_COMMAND:-bash -l}
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|||||||
@@ -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"
|
|
||||||
Reference in New Issue
Block a user