diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 000000000..cda24926d --- /dev/null +++ b/appspec.yml @@ -0,0 +1,20 @@ +version: 0.0 +os: linux +files: + - source: / + destination: /home/ubuntu + overwrite: yes +permission: + - object: /home/ubuntu + pattern: "**" + owner: ubuntu + group: ubuntu +hooks: + ApplicationStop: + - location: kill_process.sh + timeout: 100 + runas: ubuntu + ApplicationStart: + - location: run_process.sh + timeout: 3600 + runas: ubuntu \ No newline at end of file diff --git a/scripts/kill_process.sh b/scripts/kill_process.sh new file mode 100644 index 000000000..1259ba0d9 --- /dev/null +++ b/scripts/kill_process.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Remove existed container" +docker-compose -f /home/ec2-user/docker-compose.yml down || true + diff --git a/scripts/run_process.sh b/scripts/run_process.sh new file mode 100644 index 000000000..19c1874c3 --- /dev/null +++ b/scripts/run_process.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +REGION="ap-northeast-2" +ACCOUNT_ID="257307634175" +ECR_REPOSITORY="${ACCOUNT_ID}.dkr.ecr.ap-northeast-2.amazonaws.com" +ECR_DOCKER_IMAGE="${ECR_REPOSITORY}/spring-petclinic" +ECR_DOCKER_TAG="1.0" + +aws ecr get-login-password --region ${REGION} \ + | docker login --username AWS --password-stdin ${ECR_REPOSITORY}; + +export IMAGE=${ECR_DOCKER_IMAGE}; +export TAG=${ECR_DOCKER_TAG}; +docker-compose -f /home/ubuntu/docker-compose.yml up -d; +