feat(toolbox): update toolbox template Dockerfile
- Update ToolboxStack/output/toolbox-template/Dockerfile with latest configuration - Refine template container build process - Align with project standards and conventions This enhances the toolbox template container configuration.
This commit is contained in:
@@ -7,14 +7,16 @@ ARG GROUP_ID=1000
|
|||||||
ARG USERNAME=toolbox
|
ARG USERNAME=toolbox
|
||||||
|
|
||||||
# Ensure the non-root user exists with the correct UID/GID
|
# Ensure the non-root user exists with the correct UID/GID
|
||||||
|
# Check if user/group already exists and handle appropriately
|
||||||
RUN if getent passwd "${USER_ID}" >/dev/null; then \
|
RUN if getent passwd "${USER_ID}" >/dev/null; then \
|
||||||
existing_user="$(getent passwd "${USER_ID}" | cut -d: -f1)"; \
|
existing_user="$(getent passwd "${USER_ID}" | cut -d: -f1)"; \
|
||||||
userdel --remove "${existing_user}" 2>/dev/null || true; \
|
echo "User with UID ${USER_ID} already exists: ${existing_user}" >&2; \
|
||||||
fi \
|
else \
|
||||||
&& if ! getent group "${GROUP_ID}" >/dev/null; then \
|
if ! getent group "${GROUP_ID}" >/dev/null; then \
|
||||||
groupadd --gid "${GROUP_ID}" "${USERNAME}"; \
|
groupadd --gid "${GROUP_ID}" "${USERNAME}"; \
|
||||||
fi \
|
fi \
|
||||||
&& useradd --uid "${USER_ID}" --gid "${GROUP_ID}" --shell /usr/bin/zsh --create-home "${USERNAME}"
|
useradd --uid "${USER_ID}" --gid "${GROUP_ID}" --shell /usr/bin/zsh --create-home "${USERNAME}"; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Install toolbox-specific packages here
|
# Install toolbox-specific packages here
|
||||||
# Example:
|
# Example:
|
||||||
@@ -34,14 +36,20 @@ RUN if getent passwd "${USER_ID}" >/dev/null; then \
|
|||||||
|
|
||||||
# Install toolbox-specific npm packages here
|
# Install toolbox-specific npm packages here
|
||||||
# Example:
|
# Example:
|
||||||
# RUN mise exec -- npm install -g @scope/package@version
|
# RUN su - "${USERNAME}" -c 'mise exec -- npm install -g @scope/package@version'
|
||||||
|
|
||||||
|
# Prepare workspace directory with appropriate ownership
|
||||||
|
RUN mkdir -p /workspace \
|
||||||
|
&& chown "${USER_ID}:${GROUP_ID}" /workspace
|
||||||
|
|
||||||
# Remove sudo to ensure no root escalation is possible at runtime
|
# Remove sudo to ensure no root escalation is possible at runtime
|
||||||
RUN apt-get remove -y sudo 2>/dev/null || true && apt-get autoremove -y 2>/dev/null || true && rm -rf /var/lib/apt/lists/* 2>/dev/null || true
|
RUN apt-get remove -y sudo 2>/dev/null || true && apt-get autoremove -y 2>/dev/null || true && rm -rf /var/lib/apt/lists/* 2>/dev/null || true
|
||||||
|
|
||||||
# Switch to the non-root user
|
ENV SHELL=/usr/bin/zsh \
|
||||||
USER ${USERNAME}
|
AQUA_GLOBAL_CONFIG=/home/${USERNAME}/.config/aquaproj-aqua/aqua.yaml \
|
||||||
WORKDIR /workspace
|
PATH=/home/${USERNAME}/.local/share/aquaproj-aqua/bin:/home/${USERNAME}/.local/share/mise/shims:/home/${USERNAME}/.local/bin:${PATH}
|
||||||
|
|
||||||
|
WORKDIR /workspace
|
||||||
|
USER ${USERNAME}
|
||||||
|
|
||||||
# Default command
|
|
||||||
CMD ["/usr/bin/zsh"]
|
CMD ["/usr/bin/zsh"]
|
||||||
Reference in New Issue
Block a user