Skip to content

Commit

Permalink
Add custom user, cleanup apt, set symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
eifelmicha committed Jan 15, 2025
1 parent d4fcebc commit 60de690
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions azure/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ARG ANSIBLE_VERSION \

COPY ./ansible_collections.yml /ansible_collections.yml

RUN groupadd -g 1000 admin && useradd -u 1000 -g 1000 -s /bin/zsh -d /home/admin admin

# Install dependencies.
RUN apt-get update \
Expand Down Expand Up @@ -57,8 +58,9 @@ RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12
# Create venv and install tools
RUN python3.12 -m venv /opt/ansible_virtualenv \
&& . /opt/ansible_virtualenv/bin/activate \
&& pip3 install --no-cache-dir --no-compile ansible-core==${ANSIBLE_VERSION} ansible-lint==${ANSIBLE_LINT_VERSION} \
&& ansible-galaxy collection install -r /ansible_collections.yml
&& pip3 install --no-cache-dir --no-compile ansible-core==${ANSIBLE_VERSION} ansible-lint==${ANSIBLE_LINT_VERSION} yamllint \
&& ln -s /opt/ansible_virtualenv/bin/ansible* /usr/bin/ \
&& ln -s /opt/ansible_virtualenv/bin/yamllint /usr/bin/

# Install Packer + Plugins
RUN curl -sLSfo packer.zip https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_$(dpkg --print-architecture).zip && unzip -o packer.zip && mv packer /usr/bin -f && rm packer.zip
Expand All @@ -71,7 +73,24 @@ RUN curl -sLSfo terraform.zip https://releases.hashicorp.com/terraform/${TERRA
# Install TFlint
RUN curl -sLSfo tflint.zip https://github.com/terraform-linters/tflint/releases/download/v${TFLINT_VERSION}/tflint_linux_$(dpkg --print-architecture).zip && unzip -o tflint.zip && mv tflint /usr/bin -f && rm tflint.zip


# cleanup apt mess
RUN apt-get purge -y man-db && apt-get clean \
&& rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/doc/* \
/usr/share/man/* \
/usr/share/locale/*

# fatal: detected dubious ownership in repository at '/git'
RUN git config --global --add safe.directory /git

RUN chown -R 1000:1000 /home/admin
USER admin
WORKDIR /home/admin

RUN ansible-galaxy collection install -r ~/ansible_collections.yml

CMD ["/bin/bash"]

0 comments on commit 60de690

Please sign in to comment.