Skip to content

Latest commit

 

History

History
98 lines (84 loc) · 2.55 KB

File metadata and controls

98 lines (84 loc) · 2.55 KB

Cooking API

Requirement

DataBase Migrate Schema

sbt flywayMigrate

DataBase Input Default Data

sbt flywayFixtures

Deploy Play Framework on AWS Elastic Beanstalk Workflow

Ensure your app is production-ready. Update conf/application.conf for production settings (e.g., database URLs, ports).

0. Setup AWS and install the Elastic Beanstalk CLI (eb cli):

1. Using awsume

  1. Run awsume to switch to the desired AWS profile
awsume kane
  1. Verify the active profile with:
awsume --who

2. Install the Elastic Beanstalk CLI (eb cli)

python -m pip install awsebcli

1. Prepare the Application:

  • Ensure sbt dist generates target/universal/cooking-1.0-SNAPSHOT.zip.
  • Unzip, add the Procfile, and re-zip:
sbt dist
unzip target/universal/cooking-1.0-SNAPSHOT.zip -d .
cd cooking-1.0-SNAPSHOT
echo 'web: /var/app/current/bin/cooking -Dconfig.file=/var/app/current/conf/application.conf' > Procfile
zip -r ../cooking-1.0-SNAPSHOT.zip .
cd ../
mv cooking-1.0-SNAPSHOT.zip target/universal/
rm -rf cooking-1.0-SNAPSHOT

Generate a secure secret key:

sbt playGenerateSecret

2. Initialize Elastic Beanstalk:

eb init -p "arn:aws:elasticbeanstalk:us-east-1::platform/Corretto 11 running on 64bit Amazon Linux 2023/4.5.2" cooking-app --region us-east-1

3. Create the Environment:

  • Create a single-instance t2.micro environment (Free Tier-compliant):
eb create cooking-env --single --instance_type t2.micro --keyname cooking-key

4. Set the PLAY_SECRET Environment Variable:

  • After eb create but before eb deploy (or during eb create if deploying simultaneously):
eb setenv PLAY_HTTP_SECRET_KEY="BN\`g/7Oh6x^eFgrTclearYJFbhMhs9rGLAg@IbhB[<u?Z[Q0i][ElA6>04[ap>]VDh4;U"

5. re-deploy and restart the Application:

eb deploy

6. Check Logs

eb logs

7. destroy

eb terminate cooking-env

8. Useful commands

sudo systemctl status web.service
sudo systemctl edit --full web.service

9. Debug on the ec2

eb ssh
/bin/sh -c /var/app/current/bin/cooking -Dplay.http.secret.key="BN\`g/7Oh6x^eFgrTclearYJFbhMhs9rGLAg@IbhB[<u?Z[Q0i]
[ElA6>04[ap>]VDh4;U" -Dhttp.port=5000 -Dconfig.file=/var/app/current/conf/application.conf -Xmx512m -Xms256m


sudo -u webapp /bin/sh -c /var/app/current/bin/cooking -Dconfig.file=/var/app/current/conf/application.conf -Xmx512m -Xms256m
/bin/sh -c /var/app/current/bin/cooking -Dconfig.file=/var/app/current/conf/application.conf -Xmx512m -Xms256m