Restructuring build flows to choose user as default but be overridable
This commit is contained in:
10
itdominator-base-image/CONFIG.sh
Normal file
10
itdominator-base-image/CONFIG.sh
Normal 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}"
|
||||
@@ -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
21
itdominator-base-image/build.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 "")" >/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 $@;
|
||||
10
itdominator-base-image/env/.bash_ps1
vendored
10
itdominator-base-image/env/.bash_ps1
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user