Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
#---------------------------------------------------------------------------------------------

FROM python:3.6.4-alpine
FROM python:3.6.4-alpine3.7

ARG CLI_VERSION

# Metadata as defined at http://label-schema.org
ARG BUILD_DATE

ENV JP_VERSION="0.1.3"

LABEL maintainer="Microsoft" \
org.label-schema.schema-version="1.0" \
org.label-schema.vendor="Microsoft" \
Expand All @@ -24,32 +27,42 @@ LABEL maintainer="Microsoft" \

WORKDIR azure-cli
COPY . /azure-cli
# pip wheel - required for CLI packaging
# jmespath-terminal - we include jpterm as a useful tool
RUN pip install --no-cache-dir --upgrade pip wheel jmespath-terminal

# bash gcc make openssl-dev libffi-dev musl-dev - dependencies required for CLI
# jq - we include jq as a useful tool
# openssh - included for ssh-keygen
# ca-certificates
RUN apk add --no-cache bash gcc make openssl-dev libffi-dev musl-dev jq openssh \
ca-certificates curl openssl git && update-ca-certificates
# We also, install jp
RUN curl https://github.com/jmespath/jp/releases/download/0.1.2/jp-linux-amd64 -o /usr/local/bin/jp && chmod +x /usr/local/bin/jp

# curl - required for installing jp
# jq - we include jq as a useful tool
# pip wheel - required for CLI packaging
# jmespath-terminal - we include jpterm as a useful tool
# 1. Build packages and store in tmp dir
# 2. Install the cli and the other command modules that weren't included
# 3. Temporary fix - install azure-nspkg to remove import of pkg_resources in azure/__init__.py (to improve performance)
RUN /bin/bash -c 'TMP_PKG_DIR=$(mktemp -d); \
RUN apk add --no-cache bash openssh ca-certificates jq curl openssl git \
&& apk add --no-cache --virtual .build-deps gcc make openssl-dev libffi-dev musl-dev \
&& update-ca-certificates \
&& curl https://github.com/jmespath/jp/releases/download/${JP_VERSION}/jp-linux-amd64 -o /usr/local/bin/jp \
&& chmod +x /usr/local/bin/jp \
&& pip install --no-cache-dir --upgrade jmespath-terminal \
&& /bin/bash -c 'TMP_PKG_DIR=$(mktemp -d); \
for d in src/azure-cli src/azure-cli-core src/azure-cli-nspkg src/azure-cli-command_modules-nspkg src/command_modules/azure-cli-*/; \
do cd $d; echo $d; python setup.py bdist_wheel -d $TMP_PKG_DIR; cd -; \
done; \
[ -d privates ] && cp privates/*.whl $TMP_PKG_DIR; \
all_modules=`find $TMP_PKG_DIR -name "*.whl"`; \
pip install --no-cache-dir $all_modules; \
pip install --no-cache-dir --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg;'

# Tab completion
RUN cat /azure-cli/az.completion > ~/.bashrc
pip install --no-cache-dir --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg;' \
&& cat /azure-cli/az.completion > ~/.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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line makes no sense if we don't remove .rundeps later?

While cmd:, so: and pc: packages are automatically created virtuals, you can create your own as well. These allow for quick removal of purpose-specific packages. -- https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html#_virtuals

&& apk del .build-deps

WORKDIR /

Expand Down