- Create S3 artifact bucket with encryption and versioning - Add ECR lifecycle policy to maintain maximum 5 images - Add OutputArtifacts to build stage for deployment - Add Deploy stage with ECS provider - Update CodePipeline artifact store to use ArtifactBucket - Replace hardcoded bucket names with parameterized references - Add IAM permissions for ECS task definition and service management - Add buildspec commands to generate image definitions file
21 lines
807 B
YAML
21 lines
807 B
YAML
version: 0.2
|
|
phases:
|
|
pre_build:
|
|
commands:
|
|
- set -e
|
|
- ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
|
- REPOSITORY_URI=${ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/forgejo-repository
|
|
- aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${REPOSITORY_URI}
|
|
- GIT_TAG=$(date +%s)
|
|
build:
|
|
commands:
|
|
- set -e
|
|
- docker build -t ${REPOSITORY_URI}:${GIT_TAG} -t ${REPOSITORY_URI}:latest .
|
|
post_build:
|
|
commands:
|
|
- set -e
|
|
- docker push ${REPOSITORY_URI}:${GIT_TAG}
|
|
- docker push ${REPOSITORY_URI}:latest
|
|
- printf '[{"name":"forgejo","imageUri":"%s"}]' $REPOSITORY_URI:$GIT_TAG > imagedefinitions.json
|
|
artifacts:
|
|
files: imagedefinitions.json
|