docker - Dockerfile - 找不到满足 serverlessrepo==0.1.5 要求的版本
问题描述
以下是 aws sam 的 Dockerfile:
FROM buildpack-deps:stable
ARG PYTHON_VERSION=3.7.4
# Update and allow for apt over HTTPS
RUN apt-get update && \
apt-get install -y apt-utils
RUN apt-get install -y apt-transport-https
# download and build Python 3.7, install basic Python libraries
# (this predates pipenv so a mixture of dependencies)
ADD requirements.txt /requirements.txt
RUN cd /usr/src && \
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
tar xzf Python-${PYTHON_VERSION}.tgz && \
cd Python-${PYTHON_VERSION} && \
./configure --enable-optimizations && \
make altinstall && \
apt-get install -y python3-pip && \
pip3 install -r /requirements.txt
RUN pip3 install awscli --upgrade --user && \
pip3 install --user aws-sam-cli
这给出了错误:
ERROR: Could not find a version that satisfies the requirement serverlessrepo==0.1.5 (from aws-sam-cli) (from versions: 0.1.6, 0.1.7, 0.1.8, 0.1.9)
ERROR: No matching distribution found for serverlessrepo==0.1.5 (from aws-sam-cli)
The command '/bin/sh -c pip3 install awscli --upgrade --user && pip3 install --user aws-sam-cli' returned a non-zero code: 1
如何安装 serverlessrepo 0.1.5 版?
解决方案
SAM CLI支持Python2.7、3.6 和 3.7,并且您的 docker 映像随 python3.5 一起提供。解决方法可以是下面的内容,也可以从您的基础 docker 映像更新基础版本。
FROM buildpack-deps:stable
# Update and allow for apt over HTTPS
RUN apt-get update && \
apt-get install -y apt-utils
RUN apt-get install -y apt-transport-https
# Install python3
RUN apt-get update \
&& apt-get install -y python3-pip python3-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
RUN pip3 install awscli --upgrade --user
RUN python --version
RUN apt-get install python-pip -y
RUN python2.7 -m pip install aws-sam-cli
更新:
基本图像更改为buildpack-deps:buster
FROM buildpack-deps:buster
# Update and allow for apt over HTTPS
RUN apt-get update && \
apt-get install -y apt-utils
RUN apt-get install -y apt-transport-https
RUN apt update -y
RUN apt install python3-pip -y
RUN pip3 install awscli --upgrade --ignore-installed six
RUN python3.7 -m pip install aws-sam-cli
RUN rm /usr/bin/python
RUN ln -s /usr/bin/python3.7 /usr/bin/python
推荐阅读
- apache-kafka - Spring Cloud Stream > SendTo does not send to Kafka but directly via direct channel
- c++ - 绕道重铸tileLayer是什么
- java - 会话对象在哪里维护?或者谁管理会话对象?
- c - 为什么我的 srand(time(NULL)) 函数每次在 c 中生成相同的数字?
- dart - 以编程方式更改应用程序区域设置
- java - 灰度图像转矩阵和矩阵转灰度图像
- excel - 匹配值范围内的多个条件
- android - 在通知点击时处理特定的活动导航
- android - 为什么 mkdirs() 有时返回 false - 创建文件夹时出错
- python - 对 x 行数据框求和并替换