title: How to deploy google cloud functions using custom container image
body: <p>To enable the webdriver in my google cloud function, I created a custom container using a docker file:</p>
  <pre><code>FROM python:3.7
  COPY . /
  WORKDIR /
  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 https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
  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 https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz &gt; /tmp/google-cloud-sdk.tar.gz
  
  # Installing the package
  RUN mkdir -p /usr/local/gcloud \
    &amp;&amp; tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
    &amp;&amp; /usr/local/gcloud/google-cloud-sdk/install.sh
  
  # Adding the package path to local
  ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin
  
  #some envs
  ENV PORT 5000
  
  #copy local files
  COPY . . 
  
  CMD exec gunicorn --bind :${PORT} --workers 1 --threads 8 main:app 
  ENTRYPOINT [&quot;webcrawler&quot;]
  </code></pre>
  <p>I installed gcloud in this docker so that I will be able to use <code>gcloud deploy</code> to deploy my cloud functions. Then, I deploy my script using this cloudbuild.yaml:</p>
  <pre><code>steps:
    - name: 'us-central1-docker.pkg.dev/$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'
  </code></pre>
  <p>However, I end up getting this error for my deployment:</p>
  <pre><code>ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: invalid storage source object &quot;MY_FUN-ba7acf95-4297-46b3-b76e-1c25ba21ba03/version-14/function-source.zip&quot; in bucket &quot;gcf-sources-967732204245-us-central1&quot;: failed to get storage object: Get &quot;https://storage.googleapis.com/storage/v1/b/gcf-sources-967732204245-us-central1/o/MY_FUN-ba7acf95-4297-46b3-b76e-1c25ba21ba03%2Fversion-14%2Ffunction-source.zip?alt=json&amp;prettyPrint=false&quot;: RPC::UNREACHABLE: gslb: no reachable backends
  ERROR
  ERROR: build step 0 &quot;us-central1-docker.pkg.dev/PROJECT_ID/webcrawler-repo/webcrawler:tag1&quot; failed: step exited with non-zero status: 1
  </code></pre>
  <p>Any idea how to resolve this issue?</p>
  <p>Thanks!</p>