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

When setting 'path' parameter 'dockerfile' parameter is also needed #64

Closed
tarikdem opened this issue Oct 18, 2019 · 4 comments · Fixed by ovotech/circleci-orbs#318
Closed
Labels
bug Something isn't working

Comments

@tarikdem
Copy link
Contributor

Orb version

6.0.6

What happened

I tried building and pushed an image to ECR which is in a subfolder in my repo by providing the path parameter (path: './dir'). That failed with:

#!/bin/bash -eo pipefail
docker_tag_args=""
IFS="," read -ra DOCKER_TAGS <<< "latest"
for tag in "${DOCKER_TAGS[@]}"; do
  docker_tag_args="$docker_tag_args -t $AWS_ACCOUNT_URL/repo:$tag"
done
docker build \
   \
  -f Dockerfile \
  $docker_tag_args \
  ./dir
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/circleci/project/Dockerfile: no such file or directory
Exited with code 1
CircleCI received exit code 1

It worked only when I added both dockerfile: './dir/Dockerfile and path: './dir'

Expected behavior

Ideally, just by setting the path parameter the Docker context including Dockerfile should be set. If not, it is not stated in the docs that the dockerfile parameter is required when setting the path.

@tarikdem tarikdem added the bug Something isn't working label Oct 18, 2019
ArnabRaxit added a commit to ausseabed/processing-pipeline that referenced this issue Nov 18, 2019
@sparta-developers
Copy link

We are also experiencing this. We are on version 6.6.0

docker_tag_args=""
IFS="," read -ra DOCKER_TAGS <<< "latest,${CIRCLE_SHA1}"
for tag in "${DOCKER_TAGS[@]}"; do
  docker_tag_args="$docker_tag_args -t $AWS_ECR_URL/${AWS_ECR_REPO}:$tag"
done
docker build \
  -f Dockerfile \
  $docker_tag_args \
  /home/circleci/project/half_dome

Looking at the docker docs, it looks like the dockerfile parameter is distinct from the other path parameter.

$ cd /home/me/myapp/some/dir/really/deep
$ docker build -f /home/me/myapp/dockerfiles/debug /home/me/myapp
$ docker build -f ../../../../dockerfiles/debug /home/me/myapp

For what it's worth, we followed @tarikdem's suggestion and it worked for us.

@iynere
Copy link
Contributor

iynere commented Dec 26, 2019

thanks @tarikdem @sparta-developers ! looks like this orb's build-image command needs to be updated to match how we code this in our Docker orb:

- run:
    name: Docker build
    command: |
      docker_tag_args=""
      IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>"
      for tag in "${DOCKER_TAGS[@]}"; do
        docker_tag_args="$docker_tag_args -t <<parameters.registry>>/<<parameters.image>>:${tag}"
      done
      docker build <<#parameters.extra_build_args>><<parameters.extra_build_args>><</parameters.extra_build_args>> \
        -f <<parameters.path>>/<<parameters.dockerfile>> \
        $docker_tag_args \
        <<parameters.path>>

feel free to submit a PR, should be fairly straightforward, otherwise we will get this taken care of shortly

@iynere
Copy link
Contributor

iynere commented Dec 27, 2019

patched in circleci/aws-ecr@6.7.0

@iynere iynere closed this as completed Dec 27, 2019
mtmazurik added a commit to mtmazurik/RepositoryNook that referenced this issue Feb 1, 2020
@codebaard
Copy link

@tarikdem you saved my day. Had to deal with the exact same issue a whole day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants