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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With