Run a serverless app in google run

I am trying to understand how the serverless process works. I want to create a client-server app that will communicate and exchange messages (images and text). The server is a Python file that uses websockets. Once it is activated, it waits for a response from the client. Client is a webpage HTML/JavaScript that contains several buttons. Once a button start is activated, I want to run and initiate the server, which runs remotely in Google Cloud.

The first approach was to create a VM that always runs and checks for a client message. But now, I am trying to modify and have a seamless approach. I want it to run the serverless application and deploy the server on demand when the client presses the button. I guess to do this I need to use Google Run. I am a starter in this process, so I followed some instructions to set this up.

I have created a container there using the following setup: I have created a folder locally with all the files I need (and a docker file), and then I have run using the gcloud tool with the following:

gcloud builds submit --tag ``gcr.io/project_id/my-server

sudo gcloud run deploy emotion-server 
–image gcr.io/project_id/my-project
–platform managed 
–region europe-west1 
–allow-unauthenticated 
–port 12348 
–memory=4Gi

PROJECT_ID = project_id

The first command builds an image while the second command deploys the image on the cloud, I guess. The final step will be to run these commands from the client to activate the server.

When I do deploy, the server runs, but it seems that after that it runs continuously, do I need to do sth to stop the service? I am really not familiar with this process and any guidance and help will be really welcomed.