add nonroot-user
This commit is contained in:
parent
5b05afe684
commit
f0f3d3ec23
1 changed files with 19 additions and 5 deletions
24
Dockerfile
24
Dockerfile
|
@ -2,11 +2,25 @@ FROM python:3.12.4-bookworm
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
WORKDIR /
|
# Update the package list, install sudo, create a non-root user, and grant password-less sudo permissions
|
||||||
COPY requirements.txt .
|
# https://dev.to/izackv/running-a-docker-container-with-a-custom-non-root-user-syncing-host-and-container-permissions-26mb
|
||||||
COPY requirements.yaml .
|
RUN apt update && \
|
||||||
COPY start_tmux.sh .
|
apt install -y sudo && \
|
||||||
COPY version.sh .
|
addgroup --gid 2000 nonroot && \
|
||||||
|
adduser --uid 2000 --gid 2000 --disabled-password --gecos "" ansible-user && \
|
||||||
|
echo 'ansible-user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/* \
|
||||||
|
&& apt-get clean
|
||||||
|
|
||||||
|
# Set the non-root user as the default user
|
||||||
|
USER ansible-user
|
||||||
|
|
||||||
|
WORKDIR /home/ansible-user/
|
||||||
|
|
||||||
|
COPY --chown=ansible-user:ansible-user requirements.txt .
|
||||||
|
COPY --chown=ansible-user:ansible-user requirements.yaml .
|
||||||
|
COPY --chown=ansible-user:ansible-user start_tmux.sh .
|
||||||
|
COPY --chown=ansible-user:ansible-user version.sh .
|
||||||
|
|
||||||
# hadolint ignore=DL3013
|
# hadolint ignore=DL3013
|
||||||
RUN python3 -m pip install --no-cache-dir --upgrade pip \
|
RUN python3 -m pip install --no-cache-dir --upgrade pip \
|
||||||
|
|
Loading…
Reference in a new issue