From 09cc32800074cb5246e3239c5a5ad46cd920fe57 Mon Sep 17 00:00:00 2001 From: Rebecca Valente Date: Fri, 13 Sep 2024 18:02:43 -0300 Subject: [PATCH] devops: update --- Dockerfile | 52 +++++++++++++---------- build.sh | 7 +++ rootfs/etc/ansible/ansible.cfg | 2 +- rootfs/etc/apt/sources.list.d/extras.list | 1 - 4 files changed, 37 insertions(+), 25 deletions(-) create mode 100755 build.sh delete mode 100644 rootfs/etc/apt/sources.list.d/extras.list diff --git a/Dockerfile b/Dockerfile index f16efaf..08fcf18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,17 @@ USER root WORKDIR /app -COPY rootfs/ / - -RUN apt update -qq -y >/dev/null 2>&1 \ -&& apt install -qq -y \ +RUN export ARCH=$(dpkg --print-architecture) \ +&& apt-get update -qq -y \ +&& apt-get install -qq -y ca-certificates \ +&& echo "deb [arch=${ARCH} trusted=yes] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \ +| tee /etc/apt/sources.list.d/docker.list \ +&& apt-get update -qq -y \ +&& apt-get install -qq -y \ jq \ git \ zip \ + pipx \ curl \ bash \ make \ @@ -26,17 +30,16 @@ RUN apt update -qq -y >/dev/null 2>&1 \ python3-pip \ python3-apt \ python3-distutils \ -&& apt autoclean -y \ -&& apt autoremove -y \ -&& rm -rf /var/lib/apt/lists/* +&& apt-get autoclean -y \ +&& apt-get autoremove -y RUN git clone --depth=1 https://github.com/tfutils/tfenv.git ./tfenv \ && chmod +x ./tfenv/bin/* \ -&& mv ./tfenv/bin/* /usr/local/bin +&& ln -s /app/tfenv/bin/* /usr/local/bin RUN git clone --depth=1 https://github.com/cunymatthieu/tgenv.git ./tgenv \ && chmod +x ./tgenv/bin/* \ -&& mv ./tgenv/bin/* /usr/local/bin +&& ln -s /app/tgenv/bin/* /usr/local/bin RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ && unzip awscliv2.zip \ @@ -46,24 +49,25 @@ RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash ENV N_PREFIX=/app/n RUN curl -L https://bit.ly/n-install | bash -s -- -y -ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/n/bin +ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/n/bin:/root/.local/bin - -RUN curl -s https://api.github.com/repos/little-angry-clouds/kubernetes-binaries-managers/releases/latest \ -| jq -r '.assets[] | select(.browser_download_url | contains ("linux_amd64")) | .browser_download_url' \ -| xargs curl -sLo kbenv.tar.gz \ +RUN export ARCH=$(dpkg --print-architecture) \ +&& export SYSTEM=$(uname | tr '[:upper:]' '[:lower:]' ) \ +&& curl -s https://api.github.com/repos/little-angry-clouds/kubernetes-binaries-managers/releases/latest \ +| jq -r '.assets[] | select(.browser_download_url | contains ("'${SYSTEM}_${ARCH}'")) | .browser_download_url' \ +| xargs curl -s -L -o kbenv.tar.gz \ && tar -zxvf kbenv.tar.gz \ -&& mv kubectl-linux-amd64/kbenv /usr/bin/kbenv \ -&& mv kubectl-linux-amd64/kubectl-wrapper /usr/bin/kubectl \ -&& mv helm-linux-amd64/helmenv /usr/bin/helmenv \ -&& mv helm-linux-amd64/helm-wrapper /usr/bin/helm +&& mv kubectl-${SYSTEM}-${ARCH}/kbenv /usr/bin/kbenv \ +&& mv kubectl-${SYSTEM}-${ARCH}/kubectl-wrapper /usr/bin/kubectl \ +&& mv helm-${SYSTEM}-${ARCH}/helmenv /usr/bin/helmenv \ +&& mv helm-${SYSTEM}-${ARCH}/helm-wrapper /usr/bin/helm ENV KUBECTL_VERSION=1.28.2 ENV HELM_VERSION=3.15.4 -RUN /usr/bin/kbenv install ${KUBECTL_VERSION} \ -&& /usr/bin/kbenv use ${KUBECTL_VERSION} \ -&& /usr/bin/helmenv install ${HELM_VERSION} \ -&& /usr/bin/helmenv use ${HELM_VERSION} +RUN kbenv install ${KUBECTL_VERSION} \ +&& kbenv use ${KUBECTL_VERSION} \ +&& helmenv install ${HELM_VERSION} \ +&& helmenv use ${HELM_VERSION} ENV TF_VERSION=1.9.5 RUN tfenv install ${TF_VERSION} \ @@ -74,5 +78,7 @@ RUN tgenv install ${TG_VERSION} \ && tgenv use ${TG_VERSION} ENV ANSIBLE_VERSION=10.4.0 -RUN pip3 install ansible==${ANSIBLE_VERSION} +RUN pipx install ansible==${ANSIBLE_VERSION} +ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/n/bin:/root/.local/bin:/root/.local/pipx/venvs/ansible/bin +COPY rootfs/ / diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..ec94a75 --- /dev/null +++ b/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +docker buildx build \ + --tag rbvtopudding/devops:latest \ + --push \ + --platform linux/arm64/v8,linux/amd64 \ + . diff --git a/rootfs/etc/ansible/ansible.cfg b/rootfs/etc/ansible/ansible.cfg index 1b3a673..1a2c630 100644 --- a/rootfs/etc/ansible/ansible.cfg +++ b/rootfs/etc/ansible/ansible.cfg @@ -14,7 +14,7 @@ fact_caching = community.general.yaml fact_caching_timeout = 7200 fact_caching_connection = /tmp/ansible/cache -stdout_callback = dense +stdout_callback = debug callbacks_enabled = timer, profile_tasks callback_whitelist = timer, profile_tasks diff --git a/rootfs/etc/apt/sources.list.d/extras.list b/rootfs/etc/apt/sources.list.d/extras.list deleted file mode 100644 index 450e46e..0000000 --- a/rootfs/etc/apt/sources.list.d/extras.list +++ /dev/null @@ -1 +0,0 @@ -deb https://download.docker.com/linux/debian "bookworm" stable