Restructuring build flows to choose user as default but be overridable

This commit is contained in:
2026-05-11 01:40:08 -05:00
parent d32acfaa8c
commit ab7cd262fe
4 changed files with 24 additions and 15 deletions

View File

@@ -1,6 +1,8 @@
# 1. A: Define a base image # 1. A: Define a base image
FROM itdominator-base FROM itdominator-base
ARG USERNAME=itdominator
# 1. B: Set ENV Variables # 1. B: Set ENV Variables
ENV NVM_VERSION=0.40.3 ENV NVM_VERSION=0.40.3
ENV NODE_VERSION=24.9.0 ENV NODE_VERSION=24.9.0
@@ -27,7 +29,7 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
ENV PATH="/opt:${PATH}" ENV PATH="/opt:${PATH}"
# 2. Set the working directory inside the container # 2. Set the working directory inside the container
WORKDIR /app WORKDIR /home/${USERNAME}/app
# 3. Copy the requirements and src files # 3. Copy the requirements and src files
COPY requirements.txt . COPY requirements.txt .
@@ -37,10 +39,7 @@ COPY Docker/scripts/run.sh .
COPY Docker/opt/ /opt/ COPY Docker/opt/ /opt/
# 4. A: Install system level dependencies # 4. A: Install system level dependencies
# RUN apt update RUN apt-get update && apt-get install -y \
# RUN apt install
RUN apt-get update
RUN apt-get install -y \
--no-install-recommends \ --no-install-recommends \
--no-install-suggests \ --no-install-suggests \
clang \ clang \
@@ -51,7 +50,7 @@ RUN apt-get install -y \
gopls gopls
# 4. B: Install SDKMAN # 4. B: Install SDKMAN
USER abaddon USER ${USERNAME}
RUN curl -fsSL https://get.sdkman.io | bash RUN curl -fsSL https://get.sdkman.io | bash
USER root USER root
@@ -72,6 +71,8 @@ RUN node --version
RUN npm --version RUN npm --version
RUN java --version RUN java --version
RUN chown ${USERNAME}:${USERNAME} -R /home/${USERNAME}
# 5. Cleanup # 5. Cleanup
RUN apt-get autoremove --purge RUN apt-get autoremove --purge
RUN apt-get autoclean RUN apt-get autoclean
@@ -79,8 +80,8 @@ RUN apt-get autoclean
RUN rm -rf /var/lib/apt/lists/* RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/* RUN rm -rf /tmp/*
RUN rm -rf "${NVM_DIR}/.cache" RUN rm -rf "${NVM_DIR}/.cache"
RUN rm /app/requirements.txt RUN rm /home/${USERNAME}/app/requirements.txt
# 6. Expose Port and define the command used to run the app # 6. Expose Port and define the command used to run the app
EXPOSE 9999 EXPOSE 9999
CMD ["/app/run.sh"] CMD ["/home/itdominator/app/run.sh"]

View File

@@ -12,6 +12,9 @@ function main() {
cd "${SCRIPTPATH}/.." cd "${SCRIPTPATH}/.."
echo "Working Dir: " $(pwd) echo "Working Dir: " $(pwd)
podman build -t "${CONTAINER}" -f Docker/Dockerfile . podman build \
--build-arg USERNAME="${USER}" \
-t "${CONTAINER}" \
-f Docker/Dockerfile .
} }
main $@; main $@;

View File

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

View File

@@ -19,16 +19,19 @@ function main() {
fi fi
CODE_HOST="${HOME}/Coding" CODE_HOST="${HOME}/Coding"
CODE_CONTAINER="${HOME}/Coding" CODE_CONTAINER="${CONTAINER_HOME}/Coding"
CONFIG_HOST="${HOME}/.config/lsps" CONFIG_HOST="${HOME}/.config/lsps"
CONFIG_CONTAINER="${HOME}/.config/lsps" CONFIG_CONTAINER="${CONTAINER_HOME}/.config/lsps"
_UID=$(id -u)
_GID=$(id -g)
# --user "${_UID}:${_GID}" \
# podman run -d -m 4G \ # podman run -d -m 4G \
podman run -m 4G \ podman run -m 4G \
-p 9999:9999 \ -p 9999:9999 \
-e HOME="${HOME}" \ -e HOME="${CONTAINER_HOME}" \
-e MAVEN_OPTS="-Duser.home=${HOME}" \ -e MAVEN_OPTS="-Duser.home=${CONTAINER_HOME}" \
-e JAVA_TOOL_OPTIONS="-Duser.home=${HOME}" \ -e JAVA_TOOL_OPTIONS="-Duser.home=${CONTAINER_HOME}" \
-e JDTLS_CONFIG_PATH="${CONFIG_CONTAINER}/jdtls" \ -e JDTLS_CONFIG_PATH="${CONFIG_CONTAINER}/jdtls" \
-e JDTLS_DATA_PATH="${JDTLS_CONFIG_PATH}/data" \ -e JDTLS_DATA_PATH="${JDTLS_CONFIG_PATH}/data" \
-v "${CODE_HOST}":"${CODE_CONTAINER}" \ -v "${CODE_HOST}":"${CODE_CONTAINER}" \