From f87b156da874aa58d0f93efd6936a6993e2418f8 Mon Sep 17 00:00:00 2001 From: Efe Karakus Date: Wed, 6 May 2020 14:11:24 -0700 Subject: [PATCH] fix(pipeline): buildspec works with Dockerfiles in subdirs (#902) Fixes #893 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- templates/cicd/buildspec.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/cicd/buildspec.yml b/templates/cicd/buildspec.yml index fdee0be4e75..38361082730 100644 --- a/templates/cicd/buildspec.yml +++ b/templates/cicd/buildspec.yml @@ -54,9 +54,10 @@ phases: # - Login and push the image. - > for app in $apps; do - for docker_dir in $(cat $CODEBUILD_SRC_DIR/ecs-project/$app/manifest.yml | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))' | jq '.image.build' | sed 's/"//g'); do - cd $CODEBUILD_SRC_DIR/$docker_dir; - docker build -t $app:$tag .; + for df_rel_path in $(cat $CODEBUILD_SRC_DIR/ecs-project/$app/manifest.yml | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))' | jq '.image.build' | sed 's/"//g'); do + df_path=$CODEBUILD_SRC_DIR/$df_rel_path + df_dir_path=$(dirname "$df_path") + docker build -t $app:$tag -f $df_path $df_dir_path; image_id=$(docker images -q $app:$tag); for env in $envs; do repo=$(cat $CODEBUILD_SRC_DIR/infrastructure/$app-$env.params.json | jq '.Parameters.ContainerImage' | sed 's/"//g');