Added ai-tools image option
This commit is contained in:
63
ai-tools/Docker/Dockerfile
Normal file
63
ai-tools/Docker/Dockerfile
Normal file
@@ -0,0 +1,63 @@
|
||||
# 1. A: Define a base image
|
||||
FROM itdominator-base
|
||||
|
||||
# 1. B: Set ENV Variables
|
||||
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/abaddon/
|
||||
|
||||
# 3. A: Install dependencies
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y \
|
||||
--no-install-recommends \
|
||||
--no-install-suggests \
|
||||
tree
|
||||
|
||||
RUN curl -fsSL https://pyenv.run | bash
|
||||
RUN pyenv install ${PYTHON_VERSION} && pyenv global ${PYTHON_VERSION} && pyenv local ${PYTHON_VERSION}
|
||||
|
||||
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. Copy the requirements and src files
|
||||
COPY Docker/opt/ /opt/
|
||||
|
||||
COPY Docker/scripts/run.sh .
|
||||
RUN chmod +x /home/abaddon/run.sh
|
||||
RUN chown abaddon:abaddon -R /home/abaddon
|
||||
|
||||
USER abaddon
|
||||
RUN ollama serve & sleep 5 && ollama pull llama3.1:8b
|
||||
USER root
|
||||
|
||||
# 5. Cleanup
|
||||
RUN apt-get autoremove --purge
|
||||
RUN apt-get autoclean
|
||||
|
||||
RUN rm -rf /var/lib/apt/lists/*
|
||||
RUN rm -rf /tmp/*
|
||||
RUN mkdir -p /tmp/apps
|
||||
|
||||
# 6. Expose Port and define the command used to run the app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
CMD ["/home/abaddon/run.sh"]
|
||||
17
ai-tools/Docker/build.sh
Executable file
17
ai-tools/Docker/build.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
. scripts/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 )"
|
||||
cd "${SCRIPTPATH}/.."
|
||||
echo "Working Dir: " $(pwd)
|
||||
|
||||
podman build -t "${CONTAINER}" -f Docker/Dockerfile .
|
||||
}
|
||||
main $@;
|
||||
8
ai-tools/Docker/scripts/CONFIG.sh
Normal file
8
ai-tools/Docker/scripts/CONFIG.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/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
|
||||
|
||||
|
||||
CONTAINER="ai-tools"
|
||||
21
ai-tools/Docker/scripts/clean.sh
Executable file
21
ai-tools/Docker/scripts/clean.sh
Executable 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 "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
cd "${SCRIPTPATH}"
|
||||
echo "Working Dir: " $(pwd)
|
||||
|
||||
podman container prune
|
||||
podman image prune
|
||||
podman volume prune
|
||||
podman network prune
|
||||
}
|
||||
main $@;
|
||||
|
||||
23
ai-tools/Docker/scripts/interactive-shell.sh
Executable file
23
ai-tools/Docker/scripts/interactive-shell.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/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 not up..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
podman exec -it "${ID}" /bin/bash
|
||||
}
|
||||
main $@;
|
||||
29
ai-tools/Docker/scripts/reset.sh
Executable file
29
ai-tools/Docker/scripts/reset.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/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)
|
||||
|
||||
podman container prune
|
||||
podman image prune
|
||||
podman volume prune
|
||||
podman network prune
|
||||
|
||||
podman machine stop
|
||||
podman machine reset
|
||||
# podman machine init
|
||||
podman machine init --rootful
|
||||
podman machine set --memory 4096
|
||||
# podman machine set --cpus 2 --memory 4096
|
||||
podman machine start
|
||||
}
|
||||
main $@;
|
||||
|
||||
21
ai-tools/Docker/scripts/run.sh
Executable file
21
ai-tools/Docker/scripts/run.sh
Executable 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
|
||||
set -e
|
||||
|
||||
|
||||
function main() {
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
cd "${SCRIPTPATH}"
|
||||
echo "Working Dir: " $(pwd)
|
||||
|
||||
trap "kill 0" SIGTERM SIGINT
|
||||
|
||||
# ollama launch opencode --model llama3.1
|
||||
ollama serve
|
||||
}
|
||||
main $@;
|
||||
17
ai-tools/Docker/scripts/save.sh
Executable file
17
ai-tools/Docker/scripts/save.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/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)
|
||||
|
||||
podman save -o "${CONTAINER}" $1
|
||||
}
|
||||
main $@;
|
||||
17
ai-tools/Docker/scripts/shrink.sh
Executable file
17
ai-tools/Docker/scripts/shrink.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/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)
|
||||
|
||||
qemu-img resize --shrink ~/.local/share/containers/podman/machine/qemu/podman-machine-*.qcow2 30G
|
||||
}
|
||||
main $@;
|
||||
48
ai-tools/Docker/scripts/start.sh
Executable file
48
ai-tools/Docker/scripts/start.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/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 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}"
|
||||
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="${HOME}/Downloads"
|
||||
CODING_HOST="${HOME}/Coding"
|
||||
CODING_CONTAINER="${HOME}/Coding"
|
||||
|
||||
# set_routs
|
||||
# sudo sysctl net.ipv4.ip_unprivileged_port_start=80
|
||||
# -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}" \
|
||||
-v "${DOWNLOAD_HOST}":"${DOWNLOAD_CONTAINER}" \
|
||||
-v "${CODING_HOST}":"${CODING_CONTAINER}" \
|
||||
"${CONTAINER}:latest"
|
||||
|
||||
# sudo sysctl net.ipv4.ip_unprivileged_port_start=1024
|
||||
|
||||
}
|
||||
main $@;
|
||||
24
ai-tools/Docker/scripts/stop.sh
Executable file
24
ai-tools/Docker/scripts/stop.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/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 not up..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
podman container stop "${ID}"
|
||||
}
|
||||
main $@;
|
||||
Reference in New Issue
Block a user