version: 0.2 phases: pre_build: commands: - echo Logging in to Amazon ECR... - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $ECR_REPOSITORY_URI - IMAGE_TAG=$(date +%s) - echo "Image tag will be ${IMAGE_TAG}" - if [ -z "${ECR_REPOSITORY_NAME:-}" ]; then ECR_REPOSITORY_NAME="${ECR_REPOSITORY_URI##*/}"; fi build: commands: - echo Build started on `date` - echo Building Docker image for ARM64/Lambda... - docker build --platform linux/arm64 -f docker/Dockerfile -t $ECR_REPOSITORY_URI:$IMAGE_TAG -t $ECR_REPOSITORY_URI:latest . post_build: commands: - echo Build completed on `date` - echo Pushing Docker images... - docker push $ECR_REPOSITORY_URI:$IMAGE_TAG - docker push $ECR_REPOSITORY_URI:latest - echo "Image pushed with tags ${IMAGE_TAG} and latest" - IMAGE_DIGEST=$(aws ecr describe-images --repository-name "$ECR_REPOSITORY_NAME" --image-ids imageTag="$IMAGE_TAG" --query "imageDetails[0].imageDigest" --output text) - echo "IMAGE_TAG=${IMAGE_TAG}" > image-details.env - echo "IMAGE_DIGEST=${IMAGE_DIGEST}" >> image-details.env artifacts: files: - image-details.env