Unable to install az cli on alpine
Closed this issue ยท 12 comments
My Dockerfile looks like this:
FROM alpine:3.9
RUN \
apk add --no-cache ca-certificates && \
apk add --no-cache --virtual .build-deps curl && \
curl https://dl.minio.io/client/mc/release/linux-amd64/mc > /usr/bin/mc && \
chmod +x /usr/bin/mc && apk del .build-deps
RUN apk add --no-cache curl tar openssl sudo bash jq
RUN apk --update --no-cache add postgresql-client postgresql
RUN apk add --no-cache python3 && \
python3 -m ensurepip && \
rm -r /usr/lib/python*/ensurepip && \
pip3 install --upgrade pip setuptools && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
rm -r /root/.cache
RUN pip install --upgrade azure-cli --no-cache-dir
I get error like:
Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2o08bkke/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-2dlleaal/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-7bb91zpu/overlay --compile:
unable to execute 'gcc': No such file or directory
unable to execute 'gcc': No such file or directory`
No working compiler found, or bogus compiler options passed to
the compiler from Python's standard "distutils" module. See
the error messages above. Likely, the problem is not related
to CFFI but generic to the setup.py of any Python package that
tries to compile C code. (Hints: on OS/X 10.8, for errors about
-mno-fused-madd see http://stackoverflow.com/questions/22313407/
Otherwise, see https://wiki.python.org/moin/CompLangPython or
the IRC channel #python on irc.freenode.net.)
Trying to continue anyway. If you are trying to install CFFI from
a build done in a different context, you can ignore this warning.
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/cffi
copying cffi/model.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/recompiler.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/__init__.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/api.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/cparser.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/lock.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/verifier.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/commontypes.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/error.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_embedding.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.6/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/c
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.6m -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.6/c/_cffi_backend.o
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2o08bkke/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-2dlleaal/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-7bb91zpu/overlay --compile" failed with error code 1 in /tmp/pip-install-2o08bkke/cffi/
Command "/usr/bin/python3.6 /usr/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-7bb91zpu/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=18.5 wheel "cffi>=1.8,!=1.11.3; python_implementation != 'PyPy'"" failed with error code 1 in None
I have tried with python2.7 also I get the same error. Is it to with Alpine because I dont have any issues on my Mac or other machine.
Hi I figured out the issue, it working fine if I use
FROM alpine:3.9
RUN apk add --no-cache curl tar openssl sudo bash jq
RUN apk --update --no-cache add postgresql-client postgresql
ENV AZURE_CLI_VERSION 2.0.60
RUN apk add py-pip && \
apk add --virtual=build gcc libffi-dev musl-dev openssl-dev python-dev make
RUN pip --no-cache-dir install azure-cli==${AZURE_CLI_VERSION}
But when I try to use python3, I am not able to find anything similar to py-pip to make it work and it is failing.
Howdy @revanthalampally,
Tinkering with your Dockerfile just a little, updating it to the following:
FROM alpine:3.9
RUN apk add --no-cache curl tar openssl sudo bash jq python3
RUN apk --update --no-cache add postgresql-client postgresql
RUN apk add --virtual=build gcc libffi-dev musl-dev openssl-dev make python3-dev
RUN pip3 install virtualenv &&\
python3 -m virtualenv /azure-cli
ARG AZURE_CLI_VERSION=2.0.61
RUN /azure-cli/bin/python -m pip --no-cache-dir install azure-cli==${AZURE_CLI_VERSION}
I can successfully invoke the cli by running:
/azure-cli/bin/python -m azure.cli <args>
You could then create a basic launcher by putting the following in /usr/bin/az
:
#!/usr/bin/env sh
/azure-cli/bin/python -m azure.cli "$@"
Given that I've tested this workaround, I'm going to close this issue out :) Let me know if it isn't working for you though, and I'll open it back up.
Can I know what would be the dockerfile with alpine:3.7
Getting this error with 3.7
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=561 -DPSUTIL_LINUX=1 -DPSUTIL_ETHTOOL_MISSING_TYPES=1 -I/usr/include/python3.6m -c psutil/_psutil_common.c -o build/temp.linux-x86_64-3.6/psutil/_psutil_common.o
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=561 -DPSUTIL_LINUX=1 -DPSUTIL_ETHTOOL_MISSING_TYPES=1 -I/usr/include/python3.6m -c psutil/_psutil_posix.c -o build/temp.linux-x86_64-3.6/psutil/_psutil_posix.o
psutil/_psutil_posix.c:29:29: fatal error: linux/types.h: No such file or directory
#include <linux/types.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-r9sqo189/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-2vlfz8c7/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-r9sqo189/psutil/
Looks to me like you need the linux-headers package.
@marstr Yes, I had added that and it worked. Forgot to update it here thanks.
RUN apk add --virtual=build gcc libffi-dev musl-dev openssl-dev make python3-dev linux-headers
I have no luck with:
FROM alpine:3.9
ENV AZ 2.0.62
RUN apk add -U python3 bash && \
apk add --virtual=build gcc python3-dev musl-dev libffi-dev openssl-dev make && \
pip3 install azure-cli==${AZ} && \
ln -s /usr/bin/python3 /usr/bin/python
Log:
requests 2.21.0 has requirement urllib3<1.25,>=1.21.1, but you'll have urllib3 1.25 which is incompatible
azure-cli-appservice 0.2.17 has requirement cryptography<2.5, but you'll have cryptography 2.6.1 which is incompatible.
az login:
/usr/lib/python3.6/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25) or chardet (3.0.4) doesn't match a supported version!
RequestsDependencyWarning)
WARNING: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code CODE to authenticate
I face the same issue . I created a docker container using Dockerfile.
&& apk add --virtual=build gcc libffi-dev musl-dev openssl-dev make python3-dev
&& pip3 --no-cache-dir install azure-cli==${AZURE_CLI_VERSION} \
but still the Azure DevOps container job fail with the error ##[error]Azure CLI 2.x is not installed on this machine.
Can you please let me know is there anything i can do with path or do I need to install Azure cli by some other means ??
@marstr : I used your approach but still the azure cli failed with an error
/usr/local/bin/az: line 13: python: command not found
##[error]Error Code: [127]
##[debug]Processed: ##vso[task.issue type=error;]Error Code: [127]
##[debug]task result: Failed
##[error]Script failed with error: /usr/local/bin/az: line 13: python: command not found
My docker file looks like:
FROM alpine:3.10
ENV HELM_LATEST_VERSION="v3.0.0"
ENV KUBE_LATEST_VERSION="v1.16.2"
ENV AZURE_CLI_VERSION="2.0.61"
ENV RESOURCES_DIR="/resources"
ENV HELM_HOME="${RESOURCES_DIR}/.helm"
ENV LD_LIBRARY_PATH=/usr/lib:/lib
WORKDIR $RESOURCES_DIR
RUN apk add --no-cache ca-certificates=20190108-r0
&& apk add -t deps --no-cache
ca-certificates=20190108-r0
wget=1.20.3-r0
git=2.22.0-r0
&& wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl
&& chmod +x /usr/local/bin/kubectl
&& wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk
&& apk add glibc-2.30-r0.apk
&& apk add --update --no-cache
bash=5.0.0-r0
nodejs=10.16.3-r0
libstdc++=8.3.0-r0
musl=1.1.22-r3
shadow=4.6-r2
python3=3.7.5-r1
&& pip3 install --upgrade pip==19.3.1
&& wget -q https://get.helm.sh/helm-${HELM_LATEST_VERSION}-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm
&& chmod +x /usr/local/bin/helm
#&& apk add make bash py-pip
&& apk add --virtual=build gcc libffi-dev musl-dev openssl-dev make python3-dev
#&& mv /usr/bin/az /usr/local/bin
#&& chmod +x /usr/local/bin/az
&& pip3 install virtualenv
#&& python3 -m virtualenv /azure-cli
&& /usr/bin/python3 -m pip install azure-cli==${AZURE_CLI_VERSION}
&& mv /usr/bin/az /usr/local/bin
&& chmod +x /usr/local/bin/az \