无法在Google Play应用引擎中为自定义运行时环境设置Dockerfile中的环境变量

时间:2016-11-28 09:25:04

标签: python-2.7 google-app-engine environment-variables dockerfile app-engine-flexible

我在Dockerfile下面使用为app引擎设置自定义运行时环境。

Exception in thread "main" java.lang.NullPointerException
at org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore.compareTo(HardSoftScore.java:152)
at org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore.compareTo(HardSoftScore.java:30)
at org.optaplanner.core.impl.localsearch.decider.acceptor.lateacceptance.LateAcceptanceAcceptor.isAccepted(LateAcceptanceAcceptor.java:67)
at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.processMove(LocalSearchDecider.java:166)
at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.doMove(LocalSearchDecider.java:149)
at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:121)
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:72)
at org.optaplanner.core.impl.solver.DefaultSolver.runPhases(DefaultSolver.java:215)
at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:176)
at app.resourceAllocation.main(resourceAllocation.java:44)

问题:

问题是我已经下载了应用程序引擎库zip文件并将其解压缩并添加到PATH变量但仍然在通过指定的入口点运行应用程序时出现导入错误。在GAE中阅读有关docker图像的信息我发现默认情况下它在root配置文件中运行,所以我认为这个问题与更新根配置文件的PATH变量并在其他配置文件中访问它无关。

下面是堆栈跟踪

FROM ubuntu:latest   
RUN apt-get update -y  
RUN apt-get install -y python-pip build-essential libssl-dev libffi-dev python-dev libxml2-dev libxslt1-dev xmlsec1

RUN apt-get install -y curl unzip
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz  
RUN mkdir -p /usr/local/gcloud  
RUN tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz  
RUN /usr/local/gcloud/google-cloud-sdk/install.sh

RUN curl https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.40.zip > /tmp/google_appengine_1.9.40.zip  
RUN unzip /tmp/google_appengine_1.9.40.zip -d /usr/local/gae

ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin  
ENV PATH $PATH:/usr/local/gae/google_appengine/
COPY . /app  
WORKDIR /app  
EXPOSE 80  
RUN pip install -r requirements.txt  
ENTRYPOINT gunicorn -b :$PORT main:app

1 个答案:

答案 0 :(得分:1)

这应该是Dockerfile中的第一行:

FROM gcr.io/google_appengine/python-compat-multicore

您需要一个支持App Engine API的基本映像,支持标准(运行时:python27)App Engine运行时中的7个API。

您收到上面的导入错误是因为您的Dockerfile指定的运行时中没有的app引擎API。

了解更多here