From bfb1a8e95e3b467fe688d78d53f2ebe316fd1a2c Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Mon, 11 May 2026 01:15:45 -0500 Subject: [PATCH] Restructuring build flows to choose user as default but be overridable --- ai-tools/Docker/Dockerfile | 12 ++- ai-tools/Docker/build.sh | 5 +- ai-tools/Docker/scripts/CONFIG.sh | 4 +- ai-tools/Docker/scripts/start.sh | 20 ++-- itdominator-base-image/CONFIG.sh | 10 ++ itdominator-base-image/Dockerfile | 29 +++--- itdominator-base-image/build.sh | 21 ++++ itdominator-base-image/env/.bash_ps1 | 10 +- itdominator-gui-base-image/CONFIG.sh | 10 ++ itdominator-gui-base-image/Dockerfile | 103 ++++++++++++++++++++ itdominator-gui-base-image/build.sh | 19 ++++ itdominator-gui-base-image/requirements.txt | 7 ++ itdominator-gui-base-image/start.sh | 64 ++++++++++++ 13 files changed, 276 insertions(+), 38 deletions(-) create mode 100644 itdominator-base-image/CONFIG.sh create mode 100755 itdominator-base-image/build.sh create mode 100644 itdominator-gui-base-image/CONFIG.sh create mode 100644 itdominator-gui-base-image/Dockerfile create mode 100755 itdominator-gui-base-image/build.sh create mode 100644 itdominator-gui-base-image/requirements.txt create mode 100755 itdominator-gui-base-image/start.sh diff --git a/ai-tools/Docker/Dockerfile b/ai-tools/Docker/Dockerfile index d1650dc..3202a4b 100644 --- a/ai-tools/Docker/Dockerfile +++ b/ai-tools/Docker/Dockerfile @@ -1,6 +1,8 @@ # 1. A: Define a base image FROM itdominator-base +ARG USERNAME=itdominator + # 1. B: Set ENV Variables ENV NVM_VERSION=0.40.3 ENV NODE_VERSION=24.9.0 @@ -18,7 +20,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # 2. Set the working directory inside the container -WORKDIR /home/abaddon/ +WORKDIR /home/${USERNAME} # 3. A: Install dependencies RUN apt-get update @@ -42,10 +44,10 @@ RUN npm --version COPY Docker/opt/ /opt/ COPY Docker/scripts/run.sh . -RUN chmod +x /home/abaddon/run.sh -RUN chown abaddon:abaddon -R /home/abaddon +RUN chmod +x /home/${USERNAME}/run.sh +RUN chown ${USERNAME}:${USERNAME} -R /home/${USERNAME} -USER abaddon +USER ${USERNAME} RUN ollama serve & sleep 5 && ollama pull llama3.1:8b USER root @@ -58,4 +60,4 @@ RUN rm -rf /tmp/* RUN mkdir -p /tmp/apps # 6. Expose Port and define the command used to run the app -CMD ["/home/abaddon/run.sh"] +CMD ["/home/itdominator/run.sh"] diff --git a/ai-tools/Docker/build.sh b/ai-tools/Docker/build.sh index 35fe1c5..083537c 100755 --- a/ai-tools/Docker/build.sh +++ b/ai-tools/Docker/build.sh @@ -12,6 +12,9 @@ function main() { cd "${SCRIPTPATH}/.." echo "Working Dir: " $(pwd) - podman build -t "${CONTAINER}" -f Docker/Dockerfile . + podman build \ + --build-arg USERNAME="${USER}" \ + -t "${CONTAINER}" \ + -f Docker/Dockerfile . } main $@; diff --git a/ai-tools/Docker/scripts/CONFIG.sh b/ai-tools/Docker/scripts/CONFIG.sh index c091d78..de6bd30 100644 --- a/ai-tools/Docker/scripts/CONFIG.sh +++ b/ai-tools/Docker/scripts/CONFIG.sh @@ -5,4 +5,6 @@ # set -o errunset ## To exit if a variable is referenced but not set -CONTAINER="ai-tools" \ No newline at end of file +_HOME="${HOME}" +CONTAINER="ai-tools" +CONTAINER_HOME="${_HOME}" diff --git a/ai-tools/Docker/scripts/start.sh b/ai-tools/Docker/scripts/start.sh index f0bbd21..8e79d1a 100755 --- a/ai-tools/Docker/scripts/start.sh +++ b/ai-tools/Docker/scripts/start.sh @@ -7,11 +7,6 @@ # set -o errunset ## To exit if a variable is referenced but not set -function set_routs() { - sudo iptables -t nat -I OUTPUT -p tcp -o lo --dport 80 -j REDIRECT --to-ports 8080 - sudo iptables -t nat -I OUTPUT -p tcp -o lo --dport 443 -j REDIRECT --to-ports 4433 -} - function main() { SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" cd "${SCRIPTPATH}" @@ -24,20 +19,19 @@ function main() { fi DOWNLOAD_HOST="${HOME}/Downloads" - DOWNLOAD_CONTAINER="${HOME}/Downloads" + DOWNLOAD_CONTAINER="${CONTAINER_HOME}/Downloads" CODING_HOST="${HOME}/Coding" - CODING_CONTAINER="${HOME}/Coding" + CODING_CONTAINER="${CONTAINER_HOME}/Coding" - # set_routs -# sudo sysctl net.ipv4.ip_unprivileged_port_start=80 -# -p 80:80 \ -# -p 443:443 \ + # sudo sysctl net.ipv4.ip_unprivileged_port_start=80 -# podman run -m 4G \ + # -p 80:80 \ + # -p 443:443 \ + # podman run -m 4G \ podman run -d -m 4G \ --annotation run.oci.cdi.devices=all \ -e NVIDIA_DRIVER_CAPABILITIES=video,compute,utility \ - -e HOME="${HOME}" \ + -e HOME="${CONTAINER_HOME}" \ -v "${DOWNLOAD_HOST}":"${DOWNLOAD_CONTAINER}" \ -v "${CODING_HOST}":"${CODING_CONTAINER}" \ "${CONTAINER}:latest" diff --git a/itdominator-base-image/CONFIG.sh b/itdominator-base-image/CONFIG.sh new file mode 100644 index 0000000..5d3a9ab --- /dev/null +++ b/itdominator-base-image/CONFIG.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# set -o xtrace ## To debug scripts +# set -o errexit ## To exit on error +# set -o errunset ## To exit if a variable is referenced but not set + + +_HOME="${HOME}" +CONTAINER="itdominator-base" +CONTAINER_HOME="${_HOME}" diff --git a/itdominator-base-image/Dockerfile b/itdominator-base-image/Dockerfile index a8b95d5..c550801 100644 --- a/itdominator-base-image/Dockerfile +++ b/itdominator-base-image/Dockerfile @@ -5,27 +5,24 @@ # FROM alpine:latest # FROM python:3.12 # FROM debian:bookworm-slim -FROM nginx +FROM nginx:1.29 + +ARG USERNAME=itdominator +ARG UID=1000 +ARG GID=1000 # 1. B: Set ENV Variables ENV TERM=xterm-256color # 2. Setup home user -RUN groupadd -g 1000 abaddon -RUN useradd -u 1000 -g 1000 -r -s /bin/false abaddon -COPY env/* /home/abaddon/ -RUN mkdir -p /home/abaddon/Code -RUN mkdir -p /home/abaddon/Downloads -RUN mkdir -p /home/abaddon/LazyShare -RUN mkdir -p /home/abaddon/.local -RUN mkdir -p /home/abaddon/.config -RUN mkdir -p /home/abaddon/.cache -RUN mkdir -p /home/abaddon/.thumbnails -RUN chown abaddon:abaddon -R /home/abaddon +RUN groupadd -g ${GID} ${USERNAME} +RUN useradd -u ${UID} -g ${GID} -s /bin/bash -m ${USERNAME} +COPY env/* /home/${USERNAME}/ +RUN /bin/bash -c 'mkdir -p /home/${USERNAME}/{Coding,Downloads,LazyShare,.local,.config,.cache,.thumbnails}' +RUN chown ${USERNAME}:${USERNAME} -R /home/${USERNAME} # 3. A: Install dependencies -RUN apt-get update -RUN apt-get install -y \ +RUN apt-get update && apt-get install -y \ --no-install-recommends \ --no-install-suggests \ pkg-config \ @@ -61,9 +58,9 @@ RUN apt-get install -y \ # 4. Copy files over # 5. Cleanup -RUN apt-get autoremove --purge -RUN apt-get autoclean +RUN apt-get autoremove -y --purge && apt-get autoclean +RUN rm -rf /var/lib/apt/lists/* RUN rm -rf /tmp/* # 6. Expose Port and define the command used to run the app diff --git a/itdominator-base-image/build.sh b/itdominator-base-image/build.sh new file mode 100755 index 0000000..7127bc0 --- /dev/null +++ b/itdominator-base-image/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +. CONFIG.sh + +# set -o xtrace ## To debug scripts +# set -o errexit ## To exit on error +# set -o errunset ## To exit if a variable is referenced but not set + + +function main() { + SCRIPTPATH="$( cd "$(dirname "")" >/dev/null 2>&1 ; pwd -P )" + echo "Working Dir: " $(pwd) + + podman build \ + --build-arg USERNAME="${USER}" \ + --build-arg UID=$(id -u) \ + --build-arg GID=$(id -g) \ + -t "${CONTAINER}" \ + -f ./Dockerfile +} +main $@; diff --git a/itdominator-base-image/env/.bash_ps1 b/itdominator-base-image/env/.bash_ps1 index 1c03f02..c01aa3d 100644 --- a/itdominator-base-image/env/.bash_ps1 +++ b/itdominator-base-image/env/.bash_ps1 @@ -7,11 +7,17 @@ function prompt_command() { _COMMAND="parts = '$(pwd)'.split('/'); print('$(pwd)') if not len(parts) > 3 else print(f'.../{parts[-3]}/{parts[-2]}/{parts[-1]}')" _PATH=$(python <<< "${_COMMAND}" || pwd) _BRANCH="$(git rev-parse --symbolic-full-name --abbrev-ref HEAD 2>/dev/null)" + _CURRENT_HOUR=$(date +%H) + + printf '\033]7;file://%s%s\007' "$PWD" # Week Day/Month/Day : Time -- user@group -- current dir path -- git branch - PS1="\[\e[32m\]\d\[\e[m\]: \[\e[36m\]\@\[\e[m\] -- \[\e[31m\]\u\[\e[m\]@\[\e[31m\]\h\[\e[m\] -- \[\e[35m\]${_PATH}\[\e[m\] -- ${_BRANCH} \\$ " + if (( 10#$_CURRENT_HOUR > 8 && 10#$_CURRENT_HOUR < 20 )); then + PS1="\[\e[32m\]\d\[\e[m\]: \[\e[36m\]\@\[\e[m\] -- \[\e[31m\]\u\[\e[m\]@\[\e[31m\]\h\[\e[m\] -- \[\e[35m\]${_PATH}\[\e[m\] -- ${_BRANCH} \\$ " + else + PS1="\[\e[32m\]\d\[\e[m\] -- \[\e[31m\]\u\[\e[m\]@\[\e[31m\]\h\[\e[m\] -- \[\e[35m\]${_PATH}\[\e[m\] -- ${_BRANCH} \\$ " + fi } - export PROMPT_COMMAND=prompt_command diff --git a/itdominator-gui-base-image/CONFIG.sh b/itdominator-gui-base-image/CONFIG.sh new file mode 100644 index 0000000..1f1d961 --- /dev/null +++ b/itdominator-gui-base-image/CONFIG.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# set -o xtrace ## To debug scripts +# set -o errexit ## To exit on error +# set -o errunset ## To exit if a variable is referenced but not set + + +_HOME="${HOME}" +CONTAINER="itdominator-gui-base" +CONTAINER_HOME="${_HOME}" diff --git a/itdominator-gui-base-image/Dockerfile b/itdominator-gui-base-image/Dockerfile new file mode 100644 index 0000000..eef20e9 --- /dev/null +++ b/itdominator-gui-base-image/Dockerfile @@ -0,0 +1,103 @@ +# 1. A: Define a base image +FROM itdominator-base + +ARG USERNAME=itdominator + +# 1. B: Set ENV Variables +ENV DISPLAY=:0 + +ENV NVM_VERSION=0.40.3 +ENV NODE_VERSION=24.9.0 +ENV PYTHON_VERSION=3.12.12 +ENV PYTHON_SUB_VERSION=3.12 + +ENV NVM_DIR="/root/.nvm" +ENV PYENV_ROOT="/opt/pyenv" + +ENV PATH="${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH}" +ENV PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}" +ENV PATH="/opt:${PATH}" + +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +# 2. Set the working directory inside the container +WORKDIR /home/${USERNAME}/ + +# 3. A: Install dependencies +RUN apt-get update && apt-get install -y \ + --no-install-recommends \ + --no-install-suggests \ + libgl1-mesa-dri \ + libgl1 \ + libegl1 \ + libx11-6 \ + libxext6 \ + libxrender1 \ + libxi6 \ + libxtst6 \ + dbus-x11 \ + x11-apps \ + x11-utils \ + xdg-utils \ + xauth \ + fontconfig \ + fonts-dejavu-core \ + fonts-dejavu \ + fonts-dejavu-extra \ + python3-gi \ + python3-gi-cairo \ + libgtk-3-0 \ + libgtk-3-bin \ + libatk1.0-0 \ + libgdk-pixbuf-2.0-0 \ + libpango-1.0-0 \ + libpangocairo-1.0-0 \ + libcairo2 \ + libcairo-gobject2 \ + libglib2.0-0 \ + libgtksourceview-4-0 \ + libatk-bridge2.0-0 \ + gir1.2-gtk-3.0 \ + gir1.2-glib-2.0 \ + gir1.2-gdkpixbuf-2.0 \ + gir1.2-pango-1.0 \ + gir1.2-appindicator3-0 \ + gir1.2-gtksource-4 \ + gir1.2-gtksource-3.0 \ + gir1.2-webkit2-4.1 \ + gir1.2-vte-2.91 \ + gir1.2-notify-0.7 \ + gir1.2-glib-2.0 \ + gir1.2-secret-1 \ + gir1.2-keybinder-3.0 + + # --- AppIndicator (system tray) --- + # gir1.2-ayatanaappindicator3-0 \ # modern (try first) + # libayatana-appindicator3 \ + +COPY requirements.txt . +RUN curl -fsSL https://pyenv.run | bash +RUN pyenv install ${PYTHON_VERSION} && pyenv global ${PYTHON_VERSION} && pyenv local ${PYTHON_VERSION} +RUN pip install --no-cache-dir -r requirements.txt + +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v"${NVM_VERSION}"/install.sh | bash +RUN . "${NVM_DIR}/nvm.sh" && nvm install ${NODE_VERSION} +RUN . "${NVM_DIR}/nvm.sh" && nvm use v${NODE_VERSION} +RUN . "${NVM_DIR}/nvm.sh" && nvm alias default v${NODE_VERSION} + +RUN node --version +RUN npm --version + +# 4. ... + +# 5. Cleanup +RUN apt-get autoremove -y --purge +RUN apt-get autoclean + +RUN rm -rf /var/lib/apt/lists/* +RUN rm -rf /tmp/* +RUN rm requirements.txt + +# 6. Expose Port and define the command used to run the app +CMD ["bash"] diff --git a/itdominator-gui-base-image/build.sh b/itdominator-gui-base-image/build.sh new file mode 100755 index 0000000..4d08a08 --- /dev/null +++ b/itdominator-gui-base-image/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +. CONFIG.sh + +# set -o xtrace ## To debug scripts +# set -o errexit ## To exit on error +# set -o errunset ## To exit if a variable is referenced but not set + + +function main() { + SCRIPTPATH="$( cd "$(dirname "")" >/dev/null 2>&1 ; pwd -P )" + echo "Working Dir: " $(pwd) + + podman build \ + --build-arg USERNAME="${USER}" \ + -t "${CONTAINER}" \ + -f ./Dockerfile +} +main $@; diff --git a/itdominator-gui-base-image/requirements.txt b/itdominator-gui-base-image/requirements.txt new file mode 100644 index 0000000..95ea3ee --- /dev/null +++ b/itdominator-gui-base-image/requirements.txt @@ -0,0 +1,7 @@ +pycairo +PyGObject==3.48.2 +PyQt6 +PyQt6-WebEngine +PyQt6_sip +pyxdg +setproctitle \ No newline at end of file diff --git a/itdominator-gui-base-image/start.sh b/itdominator-gui-base-image/start.sh new file mode 100755 index 0000000..5d1a249 --- /dev/null +++ b/itdominator-gui-base-image/start.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +. CONFIG.sh + +# set -o xtrace ## To debug scripts +# set -o errexit ## To exit on error +# set -o errunset ## To exit if a variable is referenced but not set + + +function main() { + SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + cd "${SCRIPTPATH}" + echo "Working Dir: " $(pwd) + + ID=$(podman ps --filter "ancestor=localhost/${CONTAINER}:latest" --format "{{.ID}}") + if [ "${ID}" != "" ]; then + echo "Is up..." + exit 1 + fi + + DOWNLOAD_HOST="${HOME}/Downloads" + DOWNLOAD_CONTAINER="${CONTAINER_HOME}/Downloads" + CODING_HOST="${HOME}/Coding" + CODING_CONTAINER="${CONTAINER_HOME}/Coding" + CONFIG_HOST="${HOME}/.config/newton" + CONFIG_CONTAINER="${CONTAINER_HOME}/.config/newton" + _UID=$(id -u) + _GID=$(id -g) + _ADDR="192.168.0.2" + _X11_PORT=":0" + _DISPLAY="${_ADDR}${_X11_PORT}" + + ( + socat TCP-LISTEN:6000,fork,bind=${_ADDR} UNIX-CONNECT:/tmp/.X11-unix/X0 \ + || echo "Socat binding already set..." + ) & + + xhost SI:localuser:abaddon + + # sudo sysctl net.ipv4.ip_unprivileged_port_start=80 + + # --security-opt label=disable \ + # --userns=host \ + # --net=host \ + # --privileged \ + # -p 80:80 \ + # -p 443:443 \ + # podman run -d -m 4G \ + podman run --rm -it -m 4G \ + --user "${_UID}":"${_GID}" \ + --annotation run.oci.cdi.devices=all \ + -e NVIDIA_DRIVER_CAPABILITIES=video,compute,utility \ + -e DISPLAY="${_DISPLAY}" \ + -e GDK_BACKEND=x11 \ + -e HOME="${CONTAINER_HOME}" \ + -v /run/user/"${_UID}":/run/user/"${_UID}" \ + -v "${DOWNLOAD_HOST}":"${DOWNLOAD_CONTAINER}" \ + -v "${CODING_HOST}":"${CODING_CONTAINER}" \ + -v "${CONFIG_HOST}":"${CONFIG_CONTAINER}" \ + "${CONTAINER}:latest" bash + + # sudo sysctl net.ipv4.ip_unprivileged_port_start=1024 +} +main $@;