chetan
chetan

Reputation: 125

Not able to set environment variable in Dockerfile for Custom runtime environment in google app engine

I'm using below Dockerfile for setting up a custom runtime environment for app engine.

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

Issue:

The problem is that I have downloaded app engine library zip file and unziped it and added to the PATH variable but still while running the app through the specified entry point I'm getting import error. Reading about docker images in GAE I came to know that by default it runs in root profile so I don't think the issue is related to updating PATH variable of root profile and accessing it in some other profile.

Below is the stack trace

File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 357, in import_app  
__import__(module)
File "/app/main.py", line 6, in <module>
from com.sears.mrp.handlers.ProductRuleHandler import ProductRuleHandler  
File "/app/com/sears/mrp/handlers/ProductRuleHandler.py", line 1, in <module>
from google.appengine.ext import ndb  
ImportError: No module named google.appengine.ext
[2016-11-28 09:10:17 +0000] [10] [INFO] Worker exiting (pid: 10)
[2016-11-28 09:10:17 +0000] [5] [INFO] Shutting down: Master
[2016-11-28 09:10:17 +0000] [5] [INFO] Reason: Worker failed to boot.*


If any one has faced this issue before please provide solution, I'm clueless on that to try more.

Upvotes: 1

Views: 768

Answers (1)

atimothee
atimothee

Reputation: 658

This should be the first line in your Dockerfile:

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

You need a base image that supports the App Engine APIs supports 7 APIs in the standard (runtime: python27) App Engine runtime.

You are getting the import error above because the app engine APIs which are not available in the runtime specified by your Dockerfile.

Read more here.

Upvotes: 1

Related Questions