Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose.yml in Google Cloud Run

I have a large understanding problem when it comes to docker-compose, Dockerfile and how GCP's service Cloud Run works. This makes me unable to advance in a project I have and I am litteraly out of things to try.

I have a docker-compose.yml file with the following content:

version: '2'

services:

    # The Application
    app:
        container_name: laravel_app
        build:
            context: ./
            dockerfile: docker/app.dockerfile
        volumes:
            - ./storage:/var/www/storage

    # The Web Server
    web:
        container_name: nginx_server
        build:
            context: ./
            dockerfile: docker/web.dockerfile
        volumes:
        - ./storage/logs/:/var/log/nginx
        ports:
        - 8080:80

As you can see, it is pretty simple, two services one for the app with php and one for the server. Both have their own dockerfiles and the build is correct. Locally everything works, no issue there.

I would now like to deploy those services in a Cloud Run service on GCP. After digging I saw that it is probably only possible to deploy a service with a single Dockerfile. Is there no way to deploy docker-compose.yml containers to Cloud Run? Should I use another service?

like image 983
mikegross Avatar asked Sep 07 '20 18:09

mikegross


1 Answers

The immediate answer is: no it won't work as-is! You have to update your packaging.

  • Firstly, Cloud Run doesn't allow you to mount volume. You need to have a stateless container. Build your container with these file inside and don't load an external volume

  • Secondly, to let build a Frontend-backend architecture, I don't recommend to host the static part on Cloud Run. It's better (cheaper, faster) to store your static files on Cloud Storage (frontend) and to let the dynamic processing (backend) on Cloud Run. Then, put in front a HTTPS Global Loadbalancer, with CDN option activated. Configure 2 backend, one with a Cloud Storage backend for the front, the second a serverless NEG for Cloud Run.

yes, it's a lot of rework... Or you can use a traditional IaaS for this, with a VM but you lose all the benefit of the scalability and the serverless features.

like image 101
guillaume blaquiere Avatar answered Nov 15 '22 18:11

guillaume blaquiere