Play 2.3.7 - Docker on Elastic Beanstalk

234 views
Skip to first unread message

jaybytez

unread,
Dec 14, 2014, 4:23:31 PM12/14/14
to play-fr...@googlegroups.com
I am trying to follow some of these great blogs for building a Docker for a Play Application:


I pushed my Docker zip file to a brand new instance of Elastic Beanstalk and I cannot access the Play application.

Has anyone done any Docker work on Elastic Beanstalk?

Is there any special configuration you had to do on a brand new Elastic Beanstalk instance to expose a default play app?

Thanks.

Joe Zulli

unread,
Dec 14, 2014, 6:06:34 PM12/14/14
to play-fr...@googlegroups.com
Hi jaybytez,

I use Docker on Elastic Beanstalk with my Play 2.3.7 app, and it works great. Can you give any more specifics on the error(s) you are getting? I don't recall having to do anything special in EB itself. The SBT native packager bundled with Play does all the heavy lifting for you. For what it's worth, here's are the [only] changes I made to my build.sbt:

maintainer in Docker := "Joe Z <joe@____.com>"

dockerExposedPorts in Docker := Seq(9000, 9443)

dockerBaseImage := "dockerfile/java:oracle-java8"

For deployment, I'm using CircleCI. You can see my config in this gist. The key parts, are:

Build it: ./activator test docker:stage

Zip it: cd target/docker; zip -r ../homebay-docker-$CIRCLE_SHA1.zip

Upload it to S3: aws s3 cp $CIRCLE_ARTIFACTS/homebay-docker-$CIRCLE_SHA1.zip s3://homebay-deployments/homebay-docker-$CIRCLE_SHA1.zip

Create a new application version:
aws elasticbeanstalk create-application-version --application-name HomeBay --version-label $CIRCLE_SHA1 --source-bundle S3Bucket=homebay-deployments,S3Key=homebay-docker-$CIRCLE_SHA1.zip --region us-east-1

Switch to the new version:
aws elasticbeanstalk update-environment --environment-name homebay-web --version-label $CIRCLE_SHA1 --region us-east-1

And that should hopefully do it. 

Joe

jaybytez

unread,
Dec 14, 2014, 9:02:14 PM12/14/14
to play-fr...@googlegroups.com
I currently have created a base play java sample application.  I then ran the:

activator docker:stage

According to some other posts, I updated the Docker file to this:

FROM dockerfile/java
MAINTAINER Jay B <jay._____@_____.net>
EXPOSE 9000
ADD files /
WORKDIR /opt/docker
RUN ["chown", "-R", "daemon", "."]
RUN ["chmod", "+x", "bin/play-sample"]
USER daemon
ENTRYPOINT ["bin/play-sample"]
CMD []

I then created the Dockerrun.aws.json
{
   "AWSEBDockerrunVersion": "1",
   "Ports": [{
       "ContainerPort": "9000"
   }]
}

I then created an EBS environment with a micro 2 and a MySQL instance (even though the I am just trying to get the basic app started).  

I then manually got to the aws EBS web page and upload the zipped directory of the files and the two Docker files.  The upload appears to be successful and in the logs I can see the localhost:9000 printout.

But if I try and redeploy my application (that works on an existing EC2 instance), I get errors like this:

[2014-12-15T01:56:15.114Z] INFO  [7439]  - [CMD-AppDeploy/AppDeployStage1] : Starting activity...
[2014-12-15T01:56:15.122Z] INFO  [7439]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook] : Starting activity...
[2014-12-15T01:56:15.133Z] INFO  [7439]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/00flip.sh] : Starting activity...
[2014-12-15T01:56:16.624Z] INFO  [7439]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/00flip.sh] : Activity execution failed, because: command failed with error code 1: /opt/elasticbeanstalk/hooks/appdeploy/enact/00flip.sh
nginx: [emerg] no host in upstream ":9000" in /etc/nginx/conf.d/elasticbeanstalk-nginx-docker-upstream.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed
Failed to start nginx, abort deployment (Executor::NonZeroExitStatus)
Reply all
Reply to author
Forward
0 new messages