11

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.

maya.js
  • 1,147
  • 12
  • 25

2 Answers2

3

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...

Eric Bolinger
  • 2,722
  • 1
  • 13
  • 22
0

I am not really familiar with Scala however I believe the artifacts could be generated by Jenkins/CircleCI inside of your container that is built on Jenkins/CircleCI then the appropriate image tags referenced within your Dockerrun.aws.json.

Hope that helps.

feelobot
  • 80
  • 7