Restructuring build flows to choose user as default but be overridable

This commit is contained in:
2026-05-11 01:15:45 -05:00
parent 3fe59e9740
commit bfb1a8e95e
13 changed files with 276 additions and 38 deletions

View File

@@ -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"]

View File

@@ -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 $@;

View File

@@ -5,4 +5,6 @@
# set -o errunset ## To exit if a variable is referenced but not set
_HOME="${HOME}"
CONTAINER="ai-tools"
CONTAINER_HOME="${_HOME}"

View File

@@ -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"

View File

@@ -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}"

View File

@@ -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

21
itdominator-base-image/build.sh Executable file
View File

@@ -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 $@;

View File

@@ -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
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

View File

@@ -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}"

View File

@@ -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"]

View File

@@ -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 $@;

View File

@@ -0,0 +1,7 @@
pycairo
PyGObject==3.48.2
PyQt6
PyQt6-WebEngine
PyQt6_sip
pyxdg
setproctitle

View File

@@ -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 $@;