From a49b55fa2fb5299458483827095e70e5eebf47cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Bia=C5=82o=C5=84?= Date: Tue, 19 Nov 2024 11:44:49 +0100 Subject: [PATCH 1/4] feat(azure): replace base image with alpine --- docker-bake.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 0c7902d..99879d7 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -13,5 +13,5 @@ target "gcp" { target "azure" { target = "azure" platforms = ["linux/amd64", "linux/arm64"] - args = {"BASE_IMAGE": "mcr.microsoft.com/azure-cli:2.63.0"} + args = {"BASE_IMAGE": "alpine:3.20"} } From a0aac27ea86d3874a3299c12b7c7bedc4d82e72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Bia=C5=82o=C5=84?= Date: Tue, 19 Nov 2024 11:44:49 +0100 Subject: [PATCH 2/4] feat(azure): install azure-cli using pip --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 991d719..3a157e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,6 +56,9 @@ USER spacelift FROM base AS azure +RUN apk add --no-cache py3-pip gcc musl-dev python3-dev libffi-dev openssl-dev cargo make +RUN pip install --break-system-packages azure-cli + RUN az --version && \ terragrunt --version && \ python --version && \ From 0eec4ea7efc96853b170d3bcfc0f75a762c616ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Bia=C5=82o=C5=84?= Date: Tue, 19 Nov 2024 15:02:32 +0100 Subject: [PATCH 3/4] use multi-stage build for azure --- Dockerfile | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3a157e9..75bca63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,15 +54,26 @@ RUN gcloud --version && \ USER spacelift -FROM base AS azure +FROM base AS azure-build RUN apk add --no-cache py3-pip gcc musl-dev python3-dev libffi-dev openssl-dev cargo make -RUN pip install --break-system-packages azure-cli -RUN az --version && \ +RUN python3 -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +RUN pip install --no-cache-dir azure-cli + +FROM base AS azure + +ENV VIRTUAL_ENV=/opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +COPY --from=azure-build /opt/venv /opt/venv + +RUN apk add --no-cache py3-pip && \ + az --version && \ terragrunt --version && \ python --version && \ infracost --version USER spacelift - From 72787361bfcbe562413edd08f9b35165df72a80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Bia=C5=82o=C5=84?= Date: Tue, 19 Nov 2024 16:11:05 +0100 Subject: [PATCH 4/4] remove VIRTUAL_ENV --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 75bca63..c476e52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,6 @@ RUN pip install --no-cache-dir azure-cli FROM base AS azure -ENV VIRTUAL_ENV=/opt/venv ENV PATH="/opt/venv/bin:$PATH" COPY --from=azure-build /opt/venv /opt/venv