Search code examples
docker-composeproductiongoogle-cloud-rungoogle-cloud-build

How to run docker-compose on google cloud run?


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?


Solution

  • 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