Follow the link to create lambda function which is trigger by S3 notification event and then create code deployment.
Gitlab pipeline job will push deploy.zip to S3 so that lambda function will create code deployment for running install script on target instance by codedeploy-agent
2. Gitlab pipeline jobs to build and deploy
image_version.txt is packed in deploy.zip for codedeploy get version to deploy
Codedeploy structure:
application: service_name (app, api, myweb, etc.)
deployment group: branch_name (feature, develop, hotfix, master, integration, etc.), each one will have same or different target instancce
The script is run on target instance by codedeploy-agent install.sh
$ cat codedeploy/scripts/install.sh
#!/bin/bash
# Script is run on instance
# Get app version
dir=$(dirname "$0")
version=$(cat ${dir}/../image_version.txt)
# Tracking version
OPS_DIR="/ect/ops"
export APP_VERSION=${version}
# Compose up
docker-compose up -d app
Top comments (1)
Very useful !