図書館API、CDの事前構築
9362 ワード

CDを構築するためにAWSサービスではS 3とCodeDeployを使用している.また、お知らせを出すためにSNSとLambdaを利用しています.このため,作業は光ディスク構築と配布通知の2つに分類される.
CD実装
構築するCDプロセスは次のとおりです.
配置の設定とスクリプトの作成
S 3は、以下のファイルを圧縮してアップロードし、そのためにまずコード動作を行う.
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/app/deploy/
overwrite: yes
permissions:
- object: /
pattern: "**"
owner: ubuntu
group: ubuntu
hooks:
ApplicationStart:
- location: deploy.sh
runas: ubuntu
#!/bin/bash
REPOSITORY_DIR=/home/ubuntu/app
APP_NAME=work-assistant-api
PID_PATH=$REPOSITORY_DIR/PID
SESSION_PROPERTIES=$REPOSITORY_DIR/application-production-session-storage.yaml
THIRD_PARTY_PROPERTIES=$REPOSITORY_DIR/application-thid-party.yaml
DB_PROPERTIES=$REPOSITORY_DIR/application-production-db.yaml
echo "copy executable jar file"
cp $REPOSITORY_DIR/$APP_NAME/build/libs/*.jar $REPOSITORY_DIR
echo "check current pid"
if [ -f $PID_PATH ]; then
PID=$(cat $PID_PATH)
echo "stop current pid $PID"
kill -15 $PID
sleep 10
fi
echo "new application deploy"
echo $(ls -tr $REPOSITORY_DIR | grep .jar | tail -n 1)
JAR_NAME=$(ls -tr $REPOSITORY_DIR/ | grep .jar | tail -n 1)
echo "jar name : $REPOSITORY_DIR/$JAR_NAME"
nohup java -jar \
-Dspring.config.location=classpath:/application.yaml,$SESSION_PROPERTIES,$THIRD_PARTY_PROPERTIES,$DB_PROPERTIES \
-Dspring.profiles.active=production \
$REPOSITORY_DIR/$JAR_NAME 2>&1 & echo $! > $PID_PATH
S 3は、配備用のみのIAMを作成する
AWSを使用するには、外部サービスが認証される必要があります.そのためには、アイデンティティとアクセス管理(IAM)を作成する必要があります.




1.Jenkins->S 3(配置に関するファイルアップロード)
S 3パケットの作成
様々なファイルを格納するためのパケットを生成します.

JenkinsとS 3の接続
そして、Jenkinsにバインドされるように、プラグインをインストールして接続設定を行う.


Build>S 3アップロードに設定
生成した結果を圧縮したファイルをS 3にアップロードするために、Jenkinsでスクリプトを作成して設定します.




2.Jenkins->CodeDeploy(配置を要求)
CodeDeployme用IAMの作成


CodeDeployの導入
配置タスクの構成を指定して作成します.





Reference
この問題について(図書館API、CDの事前構築), 我々は、より多くの情報をここで見つけました https://velog.io/@ace0390/미리도서관-API-CD-구축하기テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol