Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the best practices to deploy and host artifacts for a Docker Multicontainer environment in Elasticbeanstalk for Scala Apps?

I have several Scala applications that I want to deploy in a Docker multi-container environment on Amazon's Elastic Beanstalk.

It seems like the whole process is a bit more complicated that I was expecting. So I'm really looking forward to hear some feedback for best practices and other ways to improve my entire process and be able to "automate" some steps (if possible).

This is my current process:

  1. To generate my projects' artifacts I'm using the sbt-docker plugin. This plugin generates the projects artifacts (jars and Dockerfile) under [app-route]/target/docker.
  2. I upload these artifacts (jars and Dockerfile) into a git repository (currently doing this "manually").
  3. As Amazon's Elastic Beanstalk requires for Docker multi-containers, I need an online repository to "host" the images: Could be Docker-Hub or Quay.io. Either require me to have a git repository in which it can find the artifacts to be able to generate the project's image.
  4. Having created the multi-container environment in Elastic Beanstalk, I proceed to upload the Dockerrun.aws.json file as detailed in Amazon's documentation and also the .ebextensions/elb-listeners.config file with the settings of the ports (Since I'm running multiple apps)
  5. Magic! Amazon generates my environment. Same url, different ports for all my apps (as specified in the configuration files in step 4.

I would love to find a way to automate step 2. Since this requires me to have an extra repo per each app. I have my apps hosted in a git repo, and I have an "extra" repo per each where I host the artifacts generated in step 1 to be able to do step 3.

like image 853
maya.js Avatar asked Jul 15 '15 22:07

maya.js


People also ask

Does Elastic Beanstalk support Docker?

Elastic Beanstalk supports the deployment of web applications from Docker containers. With Docker containers, you can define your own runtime environment.

What is Dockerrun AWS JSON?

A Dockerrun. aws. json file is an Elastic Beanstalk–specific JSON file that describes how to deploy a set of Docker containers as an Elastic Beanstalk application. You can use a Dockerrun. aws.

What is Elastic Beanstalk container?

Elastic Beanstalk is an AWS service for deploying and scaling web applications and services. It eliminates the need to manually launch AWS resources required to run applications. Using your IDE, AWS Management Console, or Git repository, you upload the Docker container image.


1 Answers

If you're willing to use a different SBT plugin for step 1, then you can automate step 2.

Although quay.io supports building your image from GitHub, they do not require it. (You can publish a local Docker image directly to your quay.io repository.)

  1. Use the sbt-native-packager plugin in project/plugins.sbt.
  2. Setup the plugin settings in build.sbt, like: dockerRespository := Some("quay.io/myaccount")
  3. Your step 1 becomes: sbt docker:stage
  4. Followed by: sbt docker:publishLocal
  5. Check your image names and tags with docker images. The new image should have a name like quay.io/myaccount/app
  6. Before you can publish to quay.io, you must docker login quay.io. Read their tutorial.
  7. Your step 2 becomes sbt docker:publish. Now your quay.io account should contain the same IMAGE ID as your local Docker daemon.

Proceed with steps 3+ on the AWS side...

like image 193
Eric Bolinger Avatar answered Oct 04 '22 20:10

Eric Bolinger