This commit is contained in:
s4616 2023-07-06 14:42:38 +09:00 committed by GitHub
parent d2e47adbac
commit 05154e0851
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

20
appspec.yml Normal file
View file

@ -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

5
scripts/kill_process.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
echo "Remove existed container"
docker-compose -f /home/ec2-user/docker-compose.yml down || true

15
scripts/run_process.sh Normal file
View file

@ -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;