This article describes pretty well how to get the initial setup working in general.
But to get this working for Spring Boot and catering for secrets I had to do a few more things.
As per the article linked above to setup initially, you will have to:
- Setup an AWS account
- Install the Elasticbeanstalk CLI
Per Project Once Off
- Ensure you have a Dockerfile in the root of your project
- Make an
application-prod.propertiesfile. Add the value
server.port=80. With Docker deploys EB seems to have 80 as the port to the container.
- In your elasticbeanstalk application configuration add the property:
- When running
eb createsay yes to the option for setting up ssh. This will make it much easier later to tail logs and other things
You will need to update the health probe so that it checks
/actuator/health and not
/ (the default). To do this:
- Go to your environment’s dashboard
- Click “Configuration” in the left menu
- Scroll down to “Load balancer” and click “edit”
- Scroll up to the “Processes” section
- Click the checkbox next to the “default” process
- Click “Actions” and “Edit”
- Under “Health check” change the “Path” to
- Click “Save”
- Finally click “Apply” at the bottom of the page for the changes to take effect
Generally, you will be doing everything from the environment’s main page:
To get there:
- Switch to the region your environment is in (this is done with a dropdown on the top left-hand side
- Click “Environments” on the left menu
- Click the “Environment Name” of the environment you want
From the environment main page:
View the overall health
- Click “Causes” to debug things like deployment issues, sudden shutdowns and startups
See running logs:
- Click “Logs” from the menu on the left
From the cli you can also use
eb logs --stream
- You can also
eb sshto login and tail logs there on the docker image:
docker logs <imageId>
- You can also
Unfortunately, there is no stop/start button.
There is luckily a workaround as described here
- Set desired instances to 0
- The time is in UTC+0 so remember to work with that
- Set the time to 5 minutes from now t give EB enough time to propagate the changes
- You should see changes pending in green and the UTC time in the right column
- Click “Apply” for the changes to start propagating
You can leave the “Schedule Action” there and simply edit the time and date when you want to use them again.
I needed this step in order to inject environment variables into a build that was failing from the start. If you do no stop the service first, EB rolls back your environment variables.
Fix this as described here. Basically, run your Gradle build as follows:
gradle build -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false
Update your Dockerfile to build using the above line.