Using Docker compose within Google App Engine

后端 未结 2 1181
感情败类
感情败类 2021-01-11 17:17

I am currently experimenting with the Google App Engine flexible environment, especially the feature allowing you to build custom runtimes by providing a Do

相关标签:
2条回答
  • 2021-01-11 17:55

    It is not possible at this time to use docker-compose to have multiple application containers within a single App Engine instance. This does seem however to be by design.

    Scaling application components independently

    If you would like to have multiple application containers, you would need to deploy them as separate App Engine services. There would still only be a single application container per service instance but there could be multiple instances of each service. This would grant you the flexibility you seek of scaling each application component independently. In addition, if the application in a container were to hang, it could not affect other services as they would reside in different VMs. An added benefit of deploying each component as a separate service is that one need not use the flexible environment for every service. For some very small tasks such as API backends or serving relatively slow-changing web content, the standard environment may suffice and may be less expensive at low resource levels.

    Communication between components

    Since one of your comments mentions getting instance IPs, I thought you might find inter-service communication useful. I'm not certain for what reason you wish to use VM instance IPs but a typical use case might be to communicate between instances or services. To do this without instance IPs, your best bet is to issue HTTP request from one service to another simply using the appropriate url. If you have a service called web and one called api, the web service can issue a request to api.mycustomdomain.com where your application is hosted and the api service will receive a request with the X-Appengine-Inbound-Appid header specified with your project ID. This can serve as a way a identifying the request as coming from your own application.

    Multicontainer application using Docker

    You mention many examples of applications including NGinx, PHP-FPM, RabbitMQ, etc.. With App Engine using custom runtimes, you can deploy any container to handle traffic as long as it responds to requests from port 8080. Keep in mind that the primary purpose of the application is to serve responses. The instances should be designed to start up and shut down quickly to be horizontally scalable. They should not be used to store any application data. That should remain outside of App Engine using tools like Cloud SQL, Cloud Datastore, BigQuery or your own Redis instance running on Compute Engine.

    I hope this clarifies a few things and answers your questions.

    0 讨论(0)
  • 2021-01-11 17:59

    You can follow following steps to create a container with docker-compose file in Google App Engine. Follow link

    1. You can build your custom image using docker-compose file

      docker-compose build

    2. Create a tag for local build

      docker tag [SOURCE_IMAGE] [HOSTNAME]/[PROJECT-ID]/[IMAGE]

    3. Push image to google registry

      docker push [HOSTNAME]/[PROJECT-ID]/[IMAGE]

    4. deploy Container

      gcloud app deploy --image-url=[HOSTNAME]/[PROJECT-ID]/[IMAGE]

    please add auth for docker commands to run.

    0 讨论(0)
提交回复
热议问题