Google App Engine is one of my favorite service of GCP.
It makes my application easy to deploy and don't need to worry about the server load.It works well with my Angular/Vue.js SPA applications.
Then I took an error in the knee...
Sorry, I mean I took an error in my App Engine Service.
Error: EROFS: read-only file system, mkdir '/srv/sessions' at Object.mkdirSync (fs.js:752:3) at Object.mkdirsSync
read-only file system ?!?!
All I just want using node-persist. For some small cache files...
Why're you doing this to me !
Here is the reason from App Engine Documents:
In App Engine, the local filesystem that your application is deployed to is not writeable. This behavior ensures the security and scalability of your application.
However, if the application needs to write and read files at runtime, App Engine provides a built-in Google Cloud Storage stream wrapper that allows you to use many of the standard PHP filesystem functions to read and write files in an App Engine PHP app.
1.I'm not a PHPer, and using Google Cloud Storage for just some cache files? NaN...
2.My program works well, I don't want to change it.(Like using Cloud Storage)
3.Using Google Computer Engine and setup server from zero? Who wants to care about the server load?
Then I found a way that it worth to try!
Cloud Run is a managed compute platform that enables you to run stateless containers that are invocable via HTTP requests. Cloud Run is serverless: it abstracts away all infrastructure management, so you can focus on what matters most — building great applications.
Humm, This is what I want.
Put my application into a container. Then upload it to Cloud Run.
It will take care of my container offer flexibility and portability of workloads.
Allright! Let's hack.
1.Create a docker file.I'm using nuxt.js
FROM node:10 WORKDIR /usr/src/app ENV PORT 8080 ENV HOST 0.0.0.0 COPY package*.json ./ RUN npm install --only=production COPY . . RUN npm run build CMD npm start
2.build docker image from dockerfile.
docker build ./ -t gcr.io/project-name/image-name:1.0
3.Push the image to your GCP container registry
docker push gcr.io/project-name/image-name:1.0
5.Click it, select 「create a service at cloud run」. A few mins, your container will run at GCP.
My Cache files works! All my program run as well as my local.
And using container to build micro-services is a good feature.
So, I will say good-bye to the GAE?
Well, GAE is still a very good service for All the time. Like SPA, You can pay more attention at your front-end.
Cloud Run just give me another choice.
To understand what you need. Then you can decide which you need to use.