When building a custom runtime in App Engine flexible environment the lines of my Dockerfile in which I am attempting to install packages seem to be being skipped over. Specifically these two:
RUN add-apt-repository ppa:ubuntugis/ppa
RUN sudo apt-get install -y gdal-bin
The terminal shows that the gcloud app deploy command starts by pulling the python runtime and then skips processing the Dockerfile until this line:
RUN virtualenv /env -p python3.7
This is my whole Dockerfile. When the App tries to start it fails as it cannot find the GDAL package installation that I try to install.
FROM ubuntu:bionic
RUN add-apt-repository ppa:ubuntugis/ppa
RUN sudo apt-get install -y gdal-bin
# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
# Use -p python3 or -p python3.7 to select python version. Default is version 2.
RUN virtualenv /env -p python3.7
# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
RUN pip install -r requirements.txt
# Add the application source code.
ADD . /
# Run a WSGI server to serve the application. gunicorn must be declared as
# a dependency in requirements.txt.
CMD gunicorn -b :$PORT main:app
As per your Dockerfile
, Cloud Build shouldn't be pulling the Python runtime but the ubuntu:bionic
image. Cloud Build will pull the Python runtime when you deploy a non-custom flex app.
I believe you need to set the proper runtime in your app.yaml file, like so:
runtime: custom
env: flex
...
instead of runtime:python
.
Also, after trying to use your Dockerfile
for a test, I noticed a couple of issues:
add-apt-repository
isn't available by default on the ubuntu:bionic
image, I had to install it manually.So your Dockerfile would look something like this:
FROM ubuntu:bionic
RUN apt-get update && apt-get install software-properties-common -y
RUN add-apt-repository ppa:ubuntugis/ppa
RUN apt-get install -y gdal-bin
...