3

I'm new to GCP, and I'm trying to deploy my spring boot web service using docker-compose. In my docker-compose.yml file, I have 3 services: my app service, mysql service and Cassandra service. Locally, It works like a charm. I added also a cloudbuild.yaml file :

steps:
- name: 'docker/compose:1.28.2'
  args: ['up', '-d']
- name: 'gcr.io/cloud-builders/docker'
  args: ['tag', 'workspace_app:latest', 'gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA']
images: ['gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA']

The build on Google cloud build is made with success. But, when I try to run the image on google cloud run, It doesn't call the docker-compose. How do I must process to use docker-compose on production?

Flair
  • 2,609
  • 1
  • 29
  • 41
alia
  • 163
  • 3
  • 12
  • Could you please further explain your objective? You specified a docker compose step on Cloud Build to build your image and I'm not sure why you expect it to be called in Cloud Run. Also, you should only [deploy](https://stackoverflow.com/a/57005586/7031308) **stateless** containers in Cloud Run, so it's not the correct platform to deploy database services. – Donnald Cucharo Apr 21 '21 at 08:20
  • On the cloud run the entypoint of the dockerfile was exectued : -java - jar. I was wishing that I could execute docker-compose up -- build on cloud run. Thenk you for the clarification – alia Apr 21 '21 at 16:03

3 Answers3

7

With Cloud Run, you can deploy only one container image. The container can contain several binaries that you can run in parallel. But keep that in mind:

  • CPU is throttled when no request are processed. Background process/app aren't recommended on Cloud Run, prefer Request/Response app on Cloud Run (a webserver).
  • Only HTTP request are supported by Cloud Run. TCP connection (such as MySQL connection) aren't supported.
  • Cloud Run is stateless. You can't persist data in it.
  • All the data are stored in memory (directory /tmp is writable). You can exceed the total size of the instance memory (your app footprint + your files stored in memory)
  • Related to the previous point, when the instance is offloaded (you don't manage that, it's serverless), you lost all what you put in memory.

Thus, MySQL and Cassandra service must be hosted elsewhere

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76
  • Thank you for this clarification :) I'll look for an other alternative. – alia Apr 21 '21 at 16:01
  • @alia Did you find a complete tutorial to send your docker compose app to Google Cloud? I'm also looking for a solution – paul Apr 21 '23 at 08:30
0
docker-compose -f dirfile/ cloudbuild.yaml up

and for check it write this command

docker images

and for check you conatiner

docker container ls -a 

and for check if container run or not write this command

docker ps
0

Finally, I deployed my solution with docker-compose on the google virtual machine instance. First, we must clone our git repository on our virtual machine instance. Then, on the cloned repository containing of course the docker-compose.yml, the dockerfile and the war file, we executed this command:

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$PWD:$PWD" \
    -w="$PWD" \
    docker/compose:1.29.1 up

And, voila, our solution is working on production with docker-compose

Flair
  • 2,609
  • 1
  • 29
  • 41
alia
  • 163
  • 3
  • 12