How to deploy google cloud functions using custom container image

  docker, gcloud, google-cloud-platform, python

To enable the webdriver in my google cloud function, I created a custom container using a docker file:

FROM python:3.7
COPY . /
RUN pip3 install -r requirements.txt
RUN apt-get update 
RUN apt-get install -y gconf-service libasound2 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libxss1 fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils

#download and install chrome
RUN wget
RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install

#install python dependencies
COPY requirements.txt requirements.txt 
RUN pip install -r ./requirements.txt 

# Downloading gcloud package
RUN curl > /tmp/google-cloud-sdk.tar.gz

# Installing the package
RUN mkdir -p /usr/local/gcloud 
  && tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz 
  && /usr/local/gcloud/google-cloud-sdk/

# Adding the package path to local
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin

#some envs

#copy local files
COPY . . 

CMD exec gunicorn --bind :${PORT} --workers 1 --threads 8 main:app 
ENTRYPOINT ["webcrawler"]

I installed gcloud in this docker so that I will be able to use gcloud deploy to deploy my cloud functions. Then, I deploy my script using this cloudbuild.yaml:

  - name: '$PROJECT_ID/webcrawler-repo/webcrawler:tag1'
    entrypoint: 'gcloud'
    args: ['functions', 'deploy', 'MY_FUN', '--trigger-topic=MY_TOPIC', '--runtime=python37', '--entry-point=main', '--region=us-central1', '--memory=512MB', '--timeout=540s']
    id: 'deploying MY_FUN'
    dir: 'MY_DIR'

However, I end up getting this error for my deployment:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: invalid storage source object "MY_FUN-ba7acf95-4297-46b3-b76e-1c25ba21ba03/version-14/" in bucket "gcf-sources-967732204245-us-central1": failed to get storage object: Get "": RPC::UNREACHABLE: gslb: no reachable backends
ERROR: build step 0 "" failed: step exited with non-zero status: 1

Any idea how to resolve this issue?


Source: Docker Questions