diff --git a/Dockerfile b/Dockerfile index f723c87baca..1c85845cf61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.4 #--------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -5,7 +6,44 @@ ARG PYTHON_VERSION="3.11" -FROM python:${PYTHON_VERSION}-alpine +FROM python:${PYTHON_VERSION}-alpine AS base + +# We don't use openssl (3.0) for now. We only install it so that users can use it. +# libintl and icu-libs - required by azure devops artifact (az extension add --name azure-devops) +RUN apk add --no-cache \ + bash bash-completion openssh-keygen ca-certificates openssl \ + curl jq git perl zip \ + libintl icu-libs libc6-compat \ + && update-ca-certificates + + +FROM base AS builder + +ARG JP_VERSION="0.2.1" +# bash gcc make openssl-dev libffi-dev musl-dev - dependencies required for CLI +RUN apk add --no-cache --virtual .build-deps gcc make openssl-dev libffi-dev musl-dev linux-headers + +WORKDIR azure-cli +COPY . /azure-cli + +# 1. Install azure-cli in /usr/local +# 2. Run trim_sdk.py to clean up un-used py files: https://github.com/Azure/azure-cli/pull/25801 +# 3. Check that az and az.completion.sh can run +# 4. Remove __pycache__. It is important that we run this at the end +RUN ./scripts/install_full.sh +RUN python3 ./scripts/trim_sdk.py +RUN /usr/local/bin/az && bash -c "source /usr/local/bin/az.completion.sh" +RUN find /usr/local/lib/python*/site-packages/azure -name __pycache__ | xargs rm -rf + +# Install jp tool +RUN < ~/.bashrc \ - && runDeps="$( \ - scanelf --needed --nobanner --recursive /usr/local \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ - | sort -u \ - )" \ - && apk add --virtual .rundeps $runDeps - -WORKDIR / - -# Remove CLI source code from the final image and normalize line endings. -RUN rm -rf ./azure-cli && \ - dos2unix /root/.bashrc /usr/local/bin/az +RUN --mount=from=builder,target=/mnt <