Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodePipeline build step fails if app's Dockerfile is not in root #893

Closed
efekarakus opened this issue May 4, 2020 · 4 comments · Fixed by #902
Closed

CodePipeline build step fails if app's Dockerfile is not in root #893

efekarakus opened this issue May 4, 2020 · 4 comments · Fixed by #902
Assignees
Labels
area/pipeline Issues about pipelines to release applications. type/bug Issues that are bugs.

Comments

@efekarakus
Copy link
Contributor

Description

I have a workspace structured as:

$ tree
.
├── ecs-project
│   ├── buildspec.yml
│   ├── fe
│   │   └── manifest.yml
│   └──  pipeline.yml
└── fe
    ├── Dockerfile
    ├── go.mod
    ├── go.sum
    └── main.go

pipeline init and pipeline update creates the pipeline successfully, however the build step in the pipeline fails:


[Container] 2020/05/04 20:51:05 Running command 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 .;
  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');
    region=$(echo $repo | cut -d'.' -f4);
    $(aws ecr get-login --no-include-email --region $region);
    docker tag $image_id $repo;
    docker push $repo;
    done;
  done;
done;

/codebuild/output/tmp/script.sh: line 6: cd: /codebuild/output/src285684034/src/fe/Dockerfile: Not a directory
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /codebuild/output/src285684034/src/Dockerfile: no such file or directory

The issue appears to be because the buildspec expects the path in the manifest to be a directory where the Dockerfile is present, whereas instead the value in the manifest points to the Dockerfile path: fe/Dockerfile instead of fe.

@efekarakus efekarakus added type/bug Issues that are bugs. area/pipeline Issues about pipelines to release applications. labels May 4, 2020
@bvtujo
Copy link
Contributor

bvtujo commented May 4, 2020

What is the exact contents of the buildspec dockerfile path? I have had app deploy fail when the manifest specifies Dockerfile, only to succeed when I change it to ./Dockerfile.

@efekarakus
Copy link
Contributor Author

in the scenario above it's "fe/Dockerfile", that's why the error is:
/codebuild/output/tmp/script.sh: line 6: cd: /codebuild/output/src285684034/src/fe/Dockerfile: Not a directory

@msafder
Copy link

msafder commented May 5, 2020

I've been running into this issue since 0.0.7. I think has to with how it's trying 'cd' to a Dockerfile path that is malformed. Look for this text below:

src/./SpatialWebInterfaceFlow

[Container] 2020/05/05 18:53:44 Running command 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 .;
  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');
    region=$(echo $repo | cut -d'.' -f4);
    $(aws ecr get-login --no-include-email --region $region);
    docker tag $image_id $repo;
    docker push $repo;
    done;
  done;
done;
/codebuild/output/tmp/script.sh: line 6: cd: /codebuild/output/src624709322/src/./SpatialWebInterfaceFlow/GraphDbInt/Dockerfile: Not a directory
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /codebuild/output/src624709322/src/Dockerfile: no such file or directory

@efekarakus efekarakus self-assigned this May 6, 2020
@mergify mergify bot closed this as completed in #902 May 6, 2020
mergify bot added a commit that referenced this issue May 6, 2020
Fixes #893

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@efekarakus
Copy link
Contributor Author

bvtujo pushed a commit to bvtujo/copilot-cli that referenced this issue May 12, 2020
Fixes aws#893

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/pipeline Issues about pipelines to release applications. type/bug Issues that are bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants