Compare commits
1 Commits
main
...
13ea1a2620
| Author | SHA1 | Date | |
|---|---|---|---|
| 13ea1a2620 |
@@ -1,113 +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:
|
|
||||||
fedora: ${{ steps.filter.outputs.fedora == 'true' }}
|
|
||||||
infra: ${{ steps.filter.outputs.infra == 'true' || steps.filter.outputs.fedora == 'true' }}
|
|
||||||
go: ${{ steps.filter.outputs.go == 'true' || steps.filter.outputs.fedora == 'true' }}
|
|
||||||
php: ${{ steps.filter.outputs.php == 'true' || steps.filter.outputs.fedora == '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']
|
|
||||||
fedora: ['containers/fedora/**']
|
|
||||||
infra: ['containers/infra/**']
|
|
||||||
go: ['containers/go/**']
|
|
||||||
php: ['containers/php/**']
|
|
||||||
|
|
||||||
base-image:
|
|
||||||
needs: [changes]
|
|
||||||
if: ${{ needs.changes.outputs.fedora == '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/fedora
|
|
||||||
tags: ${{ github.ref_name }}
|
|
||||||
context: ./containers/fedora
|
|
||||||
containerfiles: ./containers/fedora/Containerfile
|
|
||||||
- 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 }}
|
|
||||||
- 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
|
|
||||||
64
.gitea/workflows/fedora.yaml
Normal file
64
.gitea/workflows/fedora.yaml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
name: Build container
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
paths:
|
||||||
|
[
|
||||||
|
"containers/fedora/**",
|
||||||
|
"containers/go/**",
|
||||||
|
"containers/infra/**",
|
||||||
|
".gitea/workflows/kali.yaml",
|
||||||
|
]
|
||||||
|
pull_request:
|
||||||
|
branches: ["main"]
|
||||||
|
paths:
|
||||||
|
[
|
||||||
|
"containers/fedora/**",
|
||||||
|
"containers/go/**",
|
||||||
|
"containers/infra/**",
|
||||||
|
".gitea/workflows/kali.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 }}
|
||||||
|
git.plabble.org/job79/fedora: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:${{ github.ref_name }}
|
||||||
|
git.plabble.org/job79/go:latest
|
||||||
|
- 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 }}
|
||||||
|
git.plabble.org/job79/infra:latest
|
||||||
34
.gitea/workflows/kali.yaml
Normal file
34
.gitea/workflows/kali.yaml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: Build container
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
paths: ["containers/kali/**", ".gitea/workflows/kali.yaml"]
|
||||||
|
pull_request:
|
||||||
|
branches: ["main"]
|
||||||
|
paths: ["containers/kali/**", ".gitea/workflows/kali.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 kali container
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ./containers/kali
|
||||||
|
file: ./containers/kali/Containerfile
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
git.plabble.org/job79/kali:${{ github.ref_name }}
|
||||||
|
git.plabble.org/job79/kali:latest
|
||||||
@@ -1,21 +1,22 @@
|
|||||||
FROM quay.io/fedora/fedora:43
|
FROM quay.io/fedora/fedora:43
|
||||||
|
|
||||||
# === install system packages ===
|
# === install system packages ===
|
||||||
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
|
RUN dnf update -y && \
|
||||||
dnf update -y && \
|
|
||||||
dnf copr enable -y atim/lazygit && \
|
dnf copr enable -y atim/lazygit && \
|
||||||
dnf -y --setopt=keepcache=1 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 lazygit
|
zoxide git npm neovim awk jq unzip fd-find lazygit
|
||||||
|
|
||||||
# === setup user ===
|
# === setup user ===
|
||||||
RUN useradd -ms /bin/bash user && echo 'user ALL=NOPASSWD: ALL' > /etc/sudoers && mkdir -p /run/user/1000 && chown user:user /run/user/1000
|
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
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
export EDITOR=nvim \
|
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 \
|
|
||||||
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,4 +1,3 @@
|
|||||||
#!/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,7 +1,7 @@
|
|||||||
[user]
|
[user]
|
||||||
email = job@plabble.org
|
email = job@plabble.org
|
||||||
name = Job79
|
name = Job79
|
||||||
signingKey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPsqM6ABAaCTQZ+llFXD3CXrYYuIHDEnvz8IBbXddYEc job@plabble.org
|
signingKey = ~/.ssh/id_ed25519.pub
|
||||||
[gpg]
|
[gpg]
|
||||||
format = ssh
|
format = ssh
|
||||||
[commit]
|
[commit]
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
ARG TAG
|
FROM git.plabble.org/job79/fedora
|
||||||
FROM job79/fedora:${TAG}
|
|
||||||
USER root
|
USER root
|
||||||
|
RUN dnf -y install go
|
||||||
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
|
|
||||||
dnf -y --setopt=keepcache=1 install go
|
|
||||||
|
|
||||||
USER user
|
USER user
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
arg "-v $HOME/Documents/go:/home/user/Documents/go"
|
arg "-v $HOME/Documents/devc/go:/home/user/projects"
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
ARG TAG
|
FROM git.plabble.org/job79/fedora
|
||||||
FROM job79/fedora:${TAG}
|
|
||||||
USER root
|
USER root
|
||||||
|
RUN dnf -y install kubectl openssl
|
||||||
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
|
RUN curl -sL https://talos.dev/install | sh
|
||||||
dnf -y --setopt=keepcache=1 install kubectl k9s openssl age "$(curl -s https://api.github.com/repos/getsops/sops/releases/latest | jq -r '.assets[] | select(.name | test("sops-.*.x86_64.rpm$")) | .browser_download_url')" && \
|
|
||||||
curl -sL https://talos.dev/install | sh && \
|
|
||||||
curl -s https://fluxcd.io/install.sh | bash
|
|
||||||
|
|
||||||
USER user
|
USER user
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
arg "-v $HOME/Documents/infra:/home/user/Documents/infra"
|
arg "-v $HOME/Documents/devc/infra:/home/user/projects"
|
||||||
|
|||||||
17
containers/kali/Containerfile
Normal file
17
containers/kali/Containerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM docker.io/kalilinux/kali-rolling
|
||||||
|
|
||||||
|
# === install system packages ===
|
||||||
|
RUN apt update && \
|
||||||
|
apt -y install iputils-ping sudo \
|
||||||
|
zoxide git npm neovim gawk jq unzip fd-find lazygit
|
||||||
|
|
||||||
|
# === setup user ===
|
||||||
|
RUN useradd -ms /bin/bash user && \
|
||||||
|
usermod -aG sudo user && sed -i 's/^%sudo\s\+ALL=(ALL:ALL)\s\+ALL$/%sudo\tALL=(ALL:ALL)\tNOPASSWD: ALL/' /etc/sudoers && \
|
||||||
|
mkdir -p /run/user/1000 && chown user:user /run/user/1000
|
||||||
|
|
||||||
|
USER user
|
||||||
|
WORKDIR /home/user
|
||||||
|
RUN mkdir -p .config .local .cache
|
||||||
|
RUN git clone https://git.plabble.org/Job79/neovim-config.git .config/nvim
|
||||||
|
VOLUME /home/user
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
ARG TAG
|
|
||||||
FROM job79/fedora:${TAG}
|
|
||||||
USER root
|
|
||||||
|
|
||||||
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
|
|
||||||
dnf -y --setopt=keepcache=1 install php composer && \
|
|
||||||
composer global require laravel/installer
|
|
||||||
|
|
||||||
USER user
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
arg "-v $HOME/Documents/php:/home/user/Documents/php"
|
|
||||||
53
devc.sh
53
devc.sh
@@ -29,17 +29,14 @@ default_args() {
|
|||||||
# 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 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
|
# Make the user home dir a volume so it survives container
|
||||||
# restarts. Use copy to keep the files from the image.
|
# restarts. Use copy to keep the homedir files from the image.
|
||||||
arg "-v $name:/home/user:copy"
|
arg "-v $name:/home/user:copy"
|
||||||
|
|
||||||
# If there is custom configuration for the container, load
|
# If there is custom configuration for the container, load
|
||||||
# it here.
|
# it here.
|
||||||
config_file="$(dirname "$(realpath "$0")")/containers/$name/config.sh"
|
config_file="$(dirname "$(realpath "$0")")/containers/$name/config.sh"
|
||||||
[ -f "$config_file" ] && source "${config_file}"
|
[ -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
|
||||||
@@ -51,18 +48,14 @@ param_args() {
|
|||||||
arg "--device /dev/dri" ;;
|
arg "--device /dev/dri" ;;
|
||||||
-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"
|
||||||
arg "-e HOST_HOME=$HOME" # Used to translate paths.
|
arg "-e HOST_HOME=$HOME" # Use to translate paths.
|
||||||
|
arg "-e DBUS_SESSION_BUS_ADDRESS='unix:path=/tmp/bus'"
|
||||||
;;
|
;;
|
||||||
-x11) # Enable X11 support.
|
-x11)
|
||||||
arg "-v /tmp/.X11-unix:/tmp/.X11-unix"
|
|
||||||
arg "-v $XAUTHORITY:/run/user/1000/.Xauthority:ro"
|
|
||||||
arg "-e DISPLAY=$DISPLAY"
|
arg "-e DISPLAY=$DISPLAY"
|
||||||
|
arg "-v /tmp/.X11-unix:/tmp/.X11-unix"
|
||||||
arg "-e XAUTHORITY=/run/user/1000/.Xauthority"
|
arg "-e XAUTHORITY=/run/user/1000/.Xauthority"
|
||||||
;;
|
arg "-v $XAUTHORITY:/run/user/1000/.Xauthority:ro"
|
||||||
-mnt) # Mount directory.
|
|
||||||
shift
|
|
||||||
arg "-w /mnt/"
|
|
||||||
arg "-v $1:/mnt/$([ ! -d "$1" ] && echo 'file')"
|
|
||||||
;;
|
;;
|
||||||
*) # Use unknown arguments a podman arguments.
|
*) # Use unknown arguments a podman arguments.
|
||||||
arg "$1" ;;
|
arg "$1" ;;
|
||||||
@@ -72,11 +65,18 @@ param_args() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
### MAIN ###
|
### MAIN ###
|
||||||
|
# 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
|
# Get the devcontainer name from the first argument. If not
|
||||||
# provided, use the last used name when possible.
|
# provided, use the last used name when possible.
|
||||||
if [[ $# -gt 0 ]] && [[ ${1:-} != -* ]]; then
|
if [[ $# -gt 0 ]] && [[ ${1:-} != -* ]]; then
|
||||||
image="$1"
|
image="$1"
|
||||||
[[ "$image" != *:* ]] && image="$image:main"
|
|
||||||
echo "$image" >"$HOME/.local/share/devc-previous-container"
|
echo "$image" >"$HOME/.local/share/devc-previous-container"
|
||||||
shift
|
shift
|
||||||
elif [ -f "$HOME/.local/share/devc-previous-container" ]; then
|
elif [ -f "$HOME/.local/share/devc-previous-container" ]; then
|
||||||
@@ -87,27 +87,12 @@ else
|
|||||||
fi
|
fi
|
||||||
name="${image%:*}"
|
name="${image%:*}"
|
||||||
|
|
||||||
# Get container registry from the DEVC_REGISTRY env
|
# Create a new container when the container is not running or
|
||||||
# variable.
|
# when any arguments are provided.
|
||||||
if [ -n "${DEVC_REGISTRY:-}" ]; then
|
|
||||||
registry="$DEVC_REGISTRY"
|
|
||||||
else
|
|
||||||
log "registry unknown; set the DEVC_REGISTRY environment variable" 'x' 31
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get container command from the DEVC_COMMAND env variable
|
|
||||||
# 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,
|
|
||||||
# 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/$image"
|
podman run -td $(default_args) $(param_args $@) "$registry/$name"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
podman exec --detach-keys "ctrl-@" -it "$name" ${DEVC_COMMAND:-}
|
podman exec -it "$name" bash -l
|
||||||
|
|||||||
Reference in New Issue
Block a user