Create a Beanstalk Application / Environment that uses Docker.
Zip up both the files above and create a new Application Version.
Deploy the version to an environment. Within x minutes Nexus will be up and running
| commands: | |
| 01clear-if-unmounted: | |
| command: if ! mount | grep /media/nexus-data-ebs > /dev/nul; then rm -rf /media/nexus-data-ebs; fi | |
| 02attach-volume: | |
| command: aws ec2 attach-volume --region eu-west-1 --volume-id vol-xxxxxxxx --instance-id $(curl -s http://169.254.169.254/latest/meta-data/instance-id) --device /dev/sdh | |
| ignoreErrors: true | |
| 03wait: | |
| command: sleep 10 | |
| 04trymount: | |
| command: | | |
| mkdir /media/nexus-data-ebs | |
| mount /dev/sdh /media/nexus-data-ebs | |
| ignoreErrors: true | |
| 05format-if-not-already: | |
| command: if find /media/nexus-data-ebs -maxdepth 0 -empty | read v; then mkfs -t ext3 /dev/sdh; fi | |
| 06mount-volume: | |
| command: | | |
| mkdir /media/nexus-data-ebs | |
| mount /dev/sdh /media/nexus-data-ebs | |
| ignoreErrors: true | |
| 07restart-docker: | |
| command: service docker restart # We must restart Docker daemon or it wont' see the new mount |
| { | |
| "AWSEBDockerrunVersion": "1", | |
| "Image": { | |
| "Name": "sonatype/nexus3", | |
| "Update": "true" | |
| }, | |
| "Ports": [ | |
| { | |
| "ContainerPort": "8081" | |
| } | |
| ], | |
| "Volumes": [ | |
| { | |
| "HostDirectory": "/media/nexus-data-ebs", | |
| "ContainerDirectory": "/nexus-data" | |
| } | |
| ], | |
| "Logging": "/var/log/nexus" | |
| } |