1+ # Consolidate the common configuration for reuse across multiple steps.
2+ definitions :
3+ # Configure some default step values.
4+ step-defaults : &step-defaults
5+ timeout_in_minutes : 15
6+ plugins :
7+ ecr : &ecr
8+ ecr#v2.0.0:
9+ login : true
10+ no-include-email : true
11+
12+ # Specify common agent queue parameters.
13+ queues :
14+ # Docker-based tasks should run in the Docker queue.
15+ docker-agents : &docker-agents
16+ agents :
17+ queue : " docker-builders"
18+ env :
19+ # If you do not declare buildkit:1 then arguments using for --target
20+ # do not work correctly and they will build every steps.
21+ DOCKER_BUILDKIT : 1
22+ BUILDKIT_PROGRESS : plain
23+
24+ # Identify the address for the shared Buildkite ECR repository.
25+ IMAGE_REPOSITORY : " 165761832703.dkr.ecr.us-east-1.amazonaws.com/buildkite"
26+
27+ # Set this as an environment variable for automatic usage by default for all
28+ # docker-compose buildkite plugin executions.
29+ BUILDKITE_PLUGIN_DOCKER_COMPOSE_IMAGE_REPOSITORY : " $IMAGE_REPOSITORY"
30+
31+ # Define a common namespace for images to be published within the shared ECR repo.
32+ ECR_NAMESPACE : " ${IMAGE_REPOSITORY}:${BUILDKITE_PIPELINE_SLUG}"
33+
34+ # Define service directory were the Dockerfile is used
35+ DOCKERFILE_LOCATION : " ./services/app"
36+ steps :
37+ - label : " :hammer: :docker: Building Docker Image"
38+ key : " build-image"
39+ << : *step-defaults
40+ << : *docker-agents
41+ command :
42+ - " docker build --target ${DOCKERFILE_BUILD_STEP} -t ${ECR_NAMESPACE}-${BUILDKITE_BUILD_NUMBER}-${BUILDKITE_COMMIT} ${DOCKERFILE_LOCATION}"
43+ - " docker push ${ECR_NAMESPACE}-${BUILDKITE_BUILD_NUMBER}-${BUILDKITE_COMMIT}"
44+ plugins :
45+ - *ecr
46+ - seek-oss/aws-sm#v2.0.0:
47+ file :
48+ - path : services/app/.env
49+ secret-id : [NEED THIS CONFIGURED]
50+
51+ # Wait for images to finish building.
52+ - wait : ~
53+
54+ # Deploy the built application.
55+ - label : " :capistrano: Deploy"
56+ key : " deploy"
57+ timeout_in_minutes : 15
58+ depends_on : " build-image"
59+ concurrency : 1
60+ concurrency_group : ' $BUILDKITE_PIPELINE_SLUG/$BUILDKITE_BRANCH/deploy'
61+ branches :
62+ - integration
63+ - main
64+ - live
65+ plugins :
66+ # Log into ECR for this build step to access prebuilt images.
67+ - *ecr
68+
69+ # Download the prebuilt image and extract project files to the
70+ # local filesystem for further operations.
71+ - forumone/extract#v0.2.0:
72+ image : ${ECR_NAMESPACE}-${BUILDKITE_BUILD_NUMBER}-${BUILDKITE_COMMIT}
73+ from : /app
74+ to : ${DOCKERFILE_LOCATION}
75+
76+ # Execute a Capistrano deployment using the defined branch to
77+ # environment mapping.
78+ - forumone/capistrano#v0.4.0:
79+ require-stage : true
80+ branches :
81+ integration : dev
82+ main : stage
83+ live : prod
0 commit comments