By Mohammad Al Amin - Intern at IncludeSec
- Have Activator installed
Extract zip and add the bin folder to your path
- Have AWS Elastic Beanstalk CLI installed
pip install awsebcli
Test your app to make sure it is ready for deployment. Run it locally using
activator run
which should make it available onhttp://localhost:9000
Note: Do not use activator run
in deployment containers, it is not meant for deployment and will not work.
Enter activator docker:publishLocal
to automatically configure a local container image. Then run your container using docker run -p <host_port>:9000 <image_name>
where host port is the TCP port you want to map the server to run on from the container port which should be 9000 by default. If you don't know the name of your image, run docker images
.
Please note that this command will make the app listen on network all interfaces (aka 0.0.0.0
) Please ensure you're firewalled off from any non-trusted networks before you run it.
Visit http://localhost:<host_port_from_earlier>
and make sure the app is working properly.
Run activator docker:stage
to package your app and all the necessary resources as well as generate a Dockerfile that can be used to build the Docker container. These resources are stored in target/docker/stage
. Copy that entire folder to a location outside of the source tree (i.e. a location where the folder would not be a child of the root folder of the app source) such as ~
or /tmp
.
- Run
eb init
and select which region you would like to deploy to. - Provide your AWS access keys (if you dont have any, go get them).
- Create a new application and select "Docker" as your platform (pick the latest version if asked).
- (Optional) If you want to set up ssh for EC2 Instances, go ahead and do that now.
Make sure your current directory is the stage
folder that was copied earlier and edit the "Dockerfile" to include the following line:
EXPOSE 9000
Elastic Beanstalk will scan the "Dockerfile" for that line in order to know which port to map to port 80 of the public server.
Finally, run the command eb create
and name your environment. eb create
can be configured with all kinds of options such as disabling load balancing, different EC2 Instance tiers, and more. Check out the AWS EB CLI documentation for more information.
The deployed app should be up and running at the CNAME URL output by the eb create
command within about 10 minutes.
I'm just getting this error :
ERROR: Dockerfile and Dockerrun.aws.json are both missing, abort deployment
Does anybody can help me , please? Thx!