@@ -22,7 +22,9 @@ phases:
22
22
- export COLOR="false"
23
23
# Find all the local services in the workspace.
24
24
- svcs=$(./copilot-linux svc ls --local --json | jq '.services[].name' | sed 's/"//g')
25
- # Find all the environments.
25
+ # Find all the local jobs in the workspace.
26
+ - jobs=$(./copilot-linux job ls --local --json | jq '.jobs[].name' | sed 's/"//g')
27
+ # Find all the environments
26
28
- envs=$(./copilot-linux env ls --json | jq '.environments[].name' | sed 's/"//g')
27
29
# Generate the cloudformation templates.
28
30
# The tag is the build ID but we replaced the colon ':' with a dash '-'.
@@ -32,17 +34,22 @@ phases:
32
34
for svc in $svcs; do
33
35
./copilot-linux svc package -n $svc -e $env --output-dir './infrastructure' --tag $tag;
34
36
done;
37
+ for job in $jobs; do
38
+ ./copilot-linux job package -n $job -e $env --output-dir './infrastructure' --tag $tag;
39
+ done;
35
40
done;
36
41
- ls -lah ./infrastructure
42
+ # Concatenate jobs and services into one var for addons
37
43
# If addons exists, upload addons templates to each S3 bucket and write template URL to template config files.
44
+ - WORKLOADS=$(echo $jobs $svcs)
38
45
- |
39
- for svc in $svcs ; do
40
- ADDONSFILE=./infrastructure/$svc .addons.stack.yml
46
+ for workload in $WORKLOADS ; do
47
+ ADDONSFILE=./infrastructure/$workload .addons.stack.yml
41
48
if [ -f "$ADDONSFILE" ]; then
42
49
tmp=$(mktemp)
43
50
timestamp=$(date +%s){{range $bucket := .ArtifactBuckets}}
44
- aws s3 cp "$ADDONSFILE" "s3://{{$bucket.BucketName}}/manual/$timestamp/$svc .addons.stack.yml";{{range $envName := $bucket.Environments}}
45
- jq --arg a "https://{{$bucket.BucketName}}.s3-{{$bucket.Region}}.amazonaws.com/manual/$timestamp/$svc .addons.stack.yml" '.Parameters.AddonsTemplateURL = $a' ./infrastructure/$svc -{{$envName}}.params.json > "$tmp" && mv "$tmp" ./infrastructure/$svc -{{$envName}}.params.json{{end}}{{end}}
51
+ aws s3 cp "$ADDONSFILE" "s3://{{$bucket.BucketName}}/manual/$timestamp/$workload .addons.stack.yml";{{range $envName := $bucket.Environments}}
52
+ jq --arg a "https://{{$bucket.BucketName}}.s3-{{$bucket.Region}}.amazonaws.com/manual/$timestamp/$workload .addons.stack.yml" '.Parameters.AddonsTemplateURL = $a' ./infrastructure/$workload -{{$envName}}.params.json > "$tmp" && mv "$tmp" ./infrastructure/$workload -{{$envName}}.params.json{{end}}{{end}}
46
53
fi
47
54
done;
48
55
# Build images
@@ -53,8 +60,8 @@ phases:
53
60
# - Retrieve the ECR repository.
54
61
# - Login and push the image.
55
62
- >
56
- for svc in $svcs ; do
57
- manifest=$(cat $CODEBUILD_SRC_DIR/copilot/$svc /manifest.yml | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))')
63
+ for workload in $WORKLOADS ; do
64
+ manifest=$(cat $CODEBUILD_SRC_DIR/copilot/$workload /manifest.yml | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))')
58
65
image_location=$(echo $manifest | jq '.image.location')
59
66
if [ ! "$image_location" = null ]; then
60
67
echo "skipping image building because location is provided as $image_location";
@@ -79,15 +86,15 @@ phases:
79
86
build_args="$build_args--build-arg $arg "
80
87
done
81
88
fi
82
- echo "Service : $svc "
89
+ echo "Name : $workload "
83
90
echo "Relative Dockerfile path: $df_rel_path"
84
91
echo "Docker build context: $df_dir_path"
85
92
echo "Docker build args: $build_args"
86
- echo "Running command: docker build -t $svc :$tag $build_args-f $df_path $df_dir_path";
87
- docker build -t $svc :$tag $build_args-f $df_path $df_dir_path;
88
- image_id=$(docker images -q $svc :$tag);
93
+ echo "Running command: docker build -t $workload :$tag $build_args-f $df_path $df_dir_path";
94
+ docker build -t $workload :$tag $build_args-f $df_path $df_dir_path;
95
+ image_id=$(docker images -q $workload :$tag);
89
96
for env in $envs; do
90
- repo=$(cat $CODEBUILD_SRC_DIR/infrastructure/$svc -$env.params.json | jq '.Parameters.ContainerImage' | sed 's/"//g');
97
+ repo=$(cat $CODEBUILD_SRC_DIR/infrastructure/$workload -$env.params.json | jq '.Parameters.ContainerImage' | sed 's/"//g');
91
98
region=$(echo $repo | cut -d'.' -f4);
92
99
$(aws ecr get-login --no-include-email --region $region);
93
100
docker tag $image_id $repo;
@@ -96,4 +103,4 @@ phases:
96
103
done;
97
104
artifacts :
98
105
files :
99
- - " infrastructure/*"
106
+ - " infrastructure/*"
0 commit comments