client: Dockerfiles: optimize by moving useradd

Adding the finance user as late as possible within the base Dockerfile
will allow for faster build times when rebuilding with different users
(the base layers won't need to be rebuilt).
This commit is contained in:
2024-08-20 17:32:36 -07:00
parent b114e0b814
commit a9e2976748
2 changed files with 7 additions and 6 deletions

View File

@@ -22,9 +22,6 @@ FROM archlinux:base-devel
# System preparation
#
# Add `finance` user
RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@
# Add system-level user for building (won't pollute user-level UID space)
RUN useradd -m -s /bin/bash -r builder
RUN gpasswd -a builder wheel
@@ -79,6 +76,10 @@ RUN composer require ccxt/ccxt
# Shell environment
#
# Add `finance` user
USER root
RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@
USER @DOCKER_FINANCE_USER@
RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_CONF}/shell/superscript.bash\"" | tee -a ~/.bashrc
RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/completion.bash\"" | tee -a ~/.bashrc

View File

@@ -26,9 +26,6 @@ RUN groupadd -r wheel
# Remove default `ubuntu` user which may conflict with host user's UID/GID (1000:1000)
RUN userdel -r ubuntu
# Add `finance` user
RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@
# Add system-level user for building (won't pollute user-level UID space)
RUN useradd -m -s /bin/bash -r builder
RUN gpasswd -a builder wheel
@@ -83,6 +80,9 @@ RUN composer require ccxt/ccxt
# Shell environment
#
# Add `finance` user
RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@
USER @DOCKER_FINANCE_USER@
RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_CONF}/shell/superscript.bash\"" | tee -a ~/.bash_aliases
RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/completion.bash\"" | tee -a ~/.bash_aliases