问题
Below is the docker file with base image python 3.7:
FROM python:3.7-alpine3.9
ENV HOME /home/someteam
ENV PATH $HOME/.local/bin:$PATH
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN apk add --no-cache --virtual .build-deps python2-dev python3-dev gcc linux-headers musl-dev && \
addgroup someteam --gid=5566; \
adduser -G someteam -Du 5566 -h /home/someteam -s /bin/bash someteam; \
chown -R someteam $HOME;
RUN apk add --no-cache groff less bash jq curl py-pip tzdata
USER someteam
WORKDIR $HOME
RUN pip install --user --upgrade awscli aws-sam-cli;
USER root
RUN apk del .build-deps; \
rm -rf /var/cache/apk/*
USER someteam
WORKDIR $HOME
ADD somescript.sh $HOME/somescript.sh
gives error:
ERROR: serverlessrepo 0.1.8 has requirement pyyaml~=3.12, but you'll have pyyaml 5.1 which is incompatible.
ERROR: aws-sam-cli 0.18.0 has requirement PyYAML~=3.12, but you'll have pyyaml 5.1 which is incompatible.
How to install pyyaml 3.12
? with python 3.6 or python 3.7 base image
回答1:
You need to install PyYAML==3.12
for your aws-sam-cli
as you Docker image come with pyyaml 5.1
by default which have compatibility issue with aws-sam-cli
. All you need to install pyyaml 3.12
before installation of aws-sam-cli
RUN pip install PyYAML==3.12
USER someteam
WORKDIR $HOME
RUN pip install --user --upgrade awscli aws-sam-cli;
USER root
回答2:
after this pull request is released, serverlessrepo should be on 5.1. According to the PR, SAM CLI will be upgraded to 5.1 soon.
来源:https://stackoverflow.com/questions/57242577/error-serverlessrepo-0-1-8-has-requirement-pyyaml-3-12