Search code examples
google-app-enginegoogle-compute-enginegoogle-managed-vmgcloud-pythongoogle-cloud-python

How to add C libraries to Python appengine


I have a Python GAE application which also uses Google Compute Engine VM instances. I'm trying to run some 3rd party applications from the shell. When I launch the Google Cloud Shell program and type pwd, the path shows: /home/<my_username> but when I call subprocess.call() from my python code, the logs display: /home/vmagent/

So I am able to install programs from the command line into /home/<my_username> but I am unable to access those programs from within my Python app because I don't know where /home/vmagent/ is!

So I guess my question is - How do I access the Google Cloud Shell that I see on my dashboard, from within my GAE app, or from one of my Compute Cloud VM instances?


Solution

  • You have to install it with Dockerfile.

    gcloud ssh gets you into main machine, not to the container with your app. Main machine hosts dockers with different services (memcache, cloudsql proxy, etc) and only one of them is docker with your app. Which is prepared from Docker file provided by you, or from a default one (that's I guess you're using right now).

    Also, you shouldn't install anything on VM instance, it should be a stateless machine. Or you have to do the same on every new instance started for you by autoscaling, or after restart.

    So basically you have to create your own Docker file, FROM gcr.io/google_appengine/python and install everything you need from there.

    See https://cloud.google.com/appengine/docs/managed-vms/custom-runtimes