Skip to content

Commit

Permalink
Refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
eifelmicha committed Jan 15, 2025
1 parent d4fcebc commit fbe1ad8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions azure/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ PACKER_ANSIBLE_VERSION=1.1.1
PACKER_AMAZON_VERSION=1.3.2
TERRAFORM_VERSION=1.10.3
TFLINT_VERSION=0.36.0
YQ_VERSION=4.44.3
47 changes: 39 additions & 8 deletions azure/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ ARG ANSIBLE_VERSION \
PACKER_ANSIBLE_VERSION \
PACKER_AMAZON_VERSION \
TERRAFORM_VERSION \
TFLINT_VERSION

COPY ./ansible_collections.yml /ansible_collections.yml
TFLINT_VERSION \
YQ_VERSION

RUN groupadd -g 1000 admin && useradd -u 1000 -g 1000 -s /bin/bash -d /home/admin admin
COPY ansible_collections.yml /home/admin/ansible_collections.yml

# Install dependencies.
RUN apt-get update \
Expand All @@ -24,6 +25,7 @@ RUN apt-get update \
ca-certificates \
curl \
git \
less \
locales \
lsb-release \
make \
Expand Down Expand Up @@ -57,21 +59,50 @@ 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
RUN packer plugins install "github.com/hashicorp/amazon" ${PACKER_ANSIBLE_VERSION} && \
packer plugins install "github.com/hashicorp/ansible" ${PACKER_ANSIBLE_VERSION}

# Install Terraform
RUN curl -sLSfo terraform.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_$(dpkg --print-architecture).zip && unzip -o terraform.zip && mv terraform /usr/bin -f && rm terraform.zip

# 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

# Install YQ
RUN curl -sLSfo /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_$(dpkg --print-architecture) && chmod +x /usr/bin/yq

# Install Node.js
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs

# sudo for all
RUN echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# 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

CMD ["/bin/bash"]
RUN chown -R 1000:1000 /home/admin
USER admin
WORKDIR /home/admin

RUN ansible-galaxy collection install -r ~/ansible_collections.yml
RUN packer plugins install "github.com/hashicorp/amazon" ${PACKER_AMAZON_VERSION} && \
packer plugins install "github.com/hashicorp/ansible" ${PACKER_ANSIBLE_VERSION}

# No ENTRYPOINT
ENTRYPOINT []
CMD []

0 comments on commit fbe1ad8

Please sign in to comment.