Skip to content

Commit

Permalink
chore(docker): enhance container security and update packages
Browse files Browse the repository at this point in the history
- Add sudo access for worker user with NOPASSWD
- Set restrictive permissions on config and binary directories
- Update apt-utils to 2.9.28 and python3.12 to 3.12.9
  • Loading branch information
fqjony committed Feb 11, 2025
1 parent 3138ec6 commit 259bff6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN apt-get update && \
tzdata=2024b-6ubuntu1 \
curl=8.11.1-1ubuntu1 \
bash=5.2.37-1ubuntu1 \
apt-utils=2.9.18 \
apt-utils=2.9.28 \
gettext=0.23.1-1 \
gnupg=2.4.4-2ubuntu22 \
ca-certificates=20241223 \
Expand All @@ -35,7 +35,7 @@ RUN apt-get update && \
unzip=6.0-28ubuntu6 \
nano=8.3-1 \
vim=2:9.1.0861-1ubuntu1 \
python3.12=3.12.8-5 \
python3.12=3.12.9-1 \
python3-pip=25.0+dfsg-1 \
supervisor=4.2.5-3 && \
apt-get clean && \
Expand Down Expand Up @@ -104,7 +104,10 @@ RUN ARCH=$(uname -m) && \

# Create a new user and group with specific UID and GID, and set permissions
RUN groupadd -g ${GID} ${USER} && \
useradd -l -m -u ${UID} -g ${GID} -s /bin/bash ${USER}
useradd -l -m -u ${UID} -g ${GID} -s /bin/bash ${USER} && \
mkdir -p /etc/sudoers.d && \
echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USER} && \
chmod 0440 /etc/sudoers.d/${USER}

# Create the Supervisor log directory and set permissions
RUN mkdir -p /var/log/supervisor /var/run/supervisor && \
Expand All @@ -123,7 +126,10 @@ COPY bin/entrypoint.sh /usr/local/bin/entrypoint.sh

# Set permissions during build
RUN chmod +x /usr/local/bin/entrypoint.sh && \
chown -R ${UID}:${GID} /usr/local/configs
chown -R ${UID}:${GID} /usr/local/configs && \
chown -R ${UID}:${GID} /usr/local/bin && \
chown -R ${UID}:${GID} /usr/local/lib && \
chmod -R g-w,o-w /usr/local/configs /usr/local/bin /usr/local/lib

# Create a symbolic link for the supervisord configuration file
RUN ln -sf /usr/local/configs/supervisor/supervisord.conf /etc/supervisord.conf
Expand Down

0 comments on commit 259bff6

Please sign in to comment.