DEV Community

How to Deploy a Vue Application on Cloud Run

Nkere-Awaji Inwan on October 16, 2019

Introduction Deploying a vue application on cloud run is as straight forward as deploying a node application on cloud run. Deploying a...
Collapse
 
steren profile image
Steren

Doing the build as part of the start command likely hurts the startup time of your app.
You should do it as a line of your Dockerfile.

Collapse
 
enkaypeter profile image
Nkere-Awaji Inwan

Yeah it does, but building the app at build time will mean the static assets will not have access to the environment variables passed at run time. One way to optimise the application startup time is optimising the code base such that build time is as fast as possible.

Collapse
 
ricard0arabia profile image
ricard0arabia

Hi, I'm gettings this error:
"Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. "

I just changed the port to 80 instead of 8080 in nginx.conf

Collapse
 
noopurphalak profile image
Noopur Ramakant Phalak • Edited

You could have instead added

EXPOSE 8080
Enter fullscreen mode Exit fullscreen mode

in your Dockerfile and you are golden...

Collapse
 
sub8s profile image
Subrahmanya S M • Edited

How add caching for this deployed cloud run url using firebase hosting rewrites firbase.json

for firebase hosting hosted static files+ Cloud run with API we can use caching like this

"rewrites": [
{
"source": "/api/",
"run": {
"serviceId": "myservice-api",

"region": "europe-west1"

}
},
{
"source": "",
"destination": "/index.html"
}
]
and
[
{ "source":"
/user/**", "headers": [{"key": "Cache-Control", "value": "no-cache, no-store"}] }
]

what is if whole dynamic Vue with node runtime hosted in the cloud run and firabase.json
have
"rewrites": [ {
"source": "/helloworld",
"run": {
"serviceId": "helloworld", // "service name" (from when you deployed the container image)
"region": "us-central1" // optional (if omitted, default is us-central1)
}
} ]
how to do caching when we are using dynamic webapp with web firebase SDK ? and liked to firebase hosting ?

Collapse
 
pcrunn profile image
Alexander P.

Is there any reason to deploy it on an actual server rather than deploying it as a static website other than using environment variables?

Collapse
 
enkaypeter profile image
Nkere-Awaji Inwan

No reason at all depending on your needs. If you're deploying on an actual server, you will need to take a different approach. Serverless helps take some work off your hands when deploying applications. But if your use-case demands an actual server, then you go for it.