pre_builds.sh
#!/bin/bash
FILE_NAME=`ls Dockerfile`
if [ $FILE_NAME = "Dockerfile" ]
then # Dockerfile이 존재하는 경우
(ECR Docker commands)
else # Dockerfile이 존재하지 않는 경우
pip3 install flask
fi
builds.sh
#!/bin/bash
FILE_NAME=`ls Dockerfile`
if [ $FILE_NAME = "Dockerfile" ]
then # Dockerfile이 존재하는 경우
(ECR Docker commands)
else # Dockerfile이 존재하지 않는 경우
python3 ./app.py &
fi
post_builds.sh
#!/bin/bash
FILE_NAME=`ls Dockerfile`
if [ $FILE_NAME = "Dockerfile" ]
then # Dockerfile이 존재하는 경우
(ECR Docker commands) # ECR Repository로 Push
else # Dockerfile이 존재하지 않는 경우
kill -9 `pgrep -f app.py` # app.py가 작동 중이면 kill을 함
echo "Test Successfully" # 성공적으로 테스트가 끝났다는 메시지
fi
ApplicationStop.sh
#!/bin/bash
isExistApp=`pgrep -f app.py`
if [[ -n $isExistApp ]]; then
kill -9 `pgrep -f app.py`
fi
BeforeInstall.sh
#!/bin/bash
rm /home/ec2-user/app.py
appspec.yml
version: 0.0
os: linux
files:
- source: /app.py
destination: /home/ec2-user
hooks:
ApplicationStop:
- location: scripts/ApplicationStop.sh
timeout: 300
runas: root
BeforeInstall:
- location: scripts/BeforeInstall.sh
timeout: 300
runas: root
# AfterInstall:
# - location: scripts/AfterInstall.sh
# timeout: 300
# runas: root
# ApplicationStart:
# - location: scripts/ApplicationStart.sh
# timeout: 300
# runas: root
buildspec.yml
version: 0.2
phases:
install:
runtime-version:
python: 3.8
pre_build:
commands:
- ./codebuild/pre_builds.sh
build:
commands:
- ./codebuild/builds.sh
post_build:
commands:
- ./codebuild/post_builds.sh
artifacts:
files:
- '**/*'
# base-directory: base_dir
# name: worldskillsPipline
# discard-paths: no
Dockerfile
FROM amazonlinux
COPY ./app.py /app.py
COPY ./start.sh /start.sh
RUN yum -y update
RUN yum -y install python3
RUN pip3 install flask
ENTRYPOINT ["/bin/bash", "/start.sh"]
start.sh
#!/bin/bash
python3 /app.py
'Misc' 카테고리의 다른 글
Flask install & CodeDeploy Agent install (0) | 2021.10.05 |
---|---|
2020 전국기능경기대회 IT네트워크시스템 기초 1과제 해설 (0) | 2021.08.29 |
2019 전국기능경기대회 IT네트워크시스템 기초 1과제 해설 (5) | 2020.12.01 |
REC-PE구조 간단하게 살펴보기 (0) | 2018.12.13 |