I am following the tutorial on the GCP page to learn how to mount a Google Cloud Storage bucket in Google Cloud Run using GCSFuse.
I cloned the code from the official GitHub repository and created the Docker file provided in the tutorial. However, I encounter issues when trying to build and deploy the container both locally and on Google Cloud Run.
# Use the official Node.js image.
# https://hub.docker.com/_/node
FROM node:20-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
gnupg \
lsb-release \
tini && \
gcsFuseRepo=gcsfuse-`lsb_release -c -s` && \
echo "deb http://packages.cloud.google.com/apt $gcsFuseRepo main" | \
tee /etc/apt/sources.list.d/gcsfuse.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
apt-key add - && \
apt-get update && \
apt-get install -y gcsfuse && \
apt-get clean
# Set fallback mount directory
ENV MNT_DIR /mnt/gcs
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY package*.json ./
# Install production dependencies.
RUN npm install --only=production
# Copy local code to the container image.
COPY . ./
# Ensure the script is executable
RUN chmod +x /app/gcsfuse_run.sh
# Use tini to manage zombie processes and signal forwarding
# https://github.com/krallin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]
# Pass the wrapper script as arguments to tini
CMD ["/app/gcsfuse_run.sh"]
The problem arises when attempting to build the container locally using the command "docker build -t filesystem-app .", where I encounter the "E: Unable to locate package gcsfuse" error. I am using an M1 Apple MacBook Pro, and I suspect that the issue might be related to the different architectures.
However, when I try to deploy the container on Google Cloud Run, it also crashes with the following error:
Deployment failed
ERROR: (gcloud.run.deploy) Revision 'filesystem-app-00013-joh' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.
Logs URL: https://console.cloud.google.com/logs/viewer?project=projet-deploiemne&resource=cloud_run_revision/service_name/filesystem-app/revision_name/filesystem-app-00013-joh&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22filesystem-app%22%0Aresource.labels.revision_name%3D%22filesystem-app-00013-joh%22
For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
It seems that the container fails to start correctly, and I suspect it might be related to the package installation issue I encountered locally.
Steps to Reproduce:
- Clone the code from the provided GitHub repository.
- Create the Dockerfile as mentioned above.
- Run "docker build -t filesystem-app ." to build the container locally.
- Deploy the container on Google Cloud Run.
Expected Outcome: The container should build successfully locally without any package installation issues, and it should deploy and run correctly on Google Cloud Run without crashing.
Other Information:
I have tried modifying the Dockerfile to include the correct binary for the arm64 architecture, but the issue persists. I also referred to the gcsfuse documentation and Docker documentation for troubleshooting.
Any insights or solutions to resolve the package installation issue and the container crash on Google Cloud Run would be highly appreciated.
Thank you in advance for your help and suggestions.
Best regards
Posting this as a community wiki for other's sake:
Base on your error mesage Container failed to start
Note: If you build your container image on an ARM based machine, then it might not work as expected when used with Cloud Run. To solve this issue, build your image using Cloud Build.
To check if the container is listening for the requests on the expecting port. The container must listen for approaching request on the port that is defined by the Google Cloud Run and provide the PORT environment variable. Configure containers
As for @John Hanley said:
Also stated by @Guillaume Blaquiere:
Additional reference:
Building Containers
Test a Cloud Run service locally
App Engine environments
Container failed to start