question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No examples of `path` or `dockerfile` options

See original GitHub issue

I’m working on a project that has multiple Dockerfiles, each of them in a separate directory. One of those is named api, so the dockerfile is in api/Dockerfile. I have the following in my workflow:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: docker/build-push-action@v1
      with:
        path: api
        username: companyusername
        password: companypassword
        repository: company/myproject/api
        registry: companyregistry
        tags: latest

I get the following error:

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /github/workspace/api/Dockerfile: no such file or directory

However, I see the checkout action logging the following:

Initializing the repository
  /usr/bin/git init /home/runner/work/myproject/myproject

From the documentation it is unclear that I should be using some variable to determine /home/runner/work/myproject/myproject instead of /github/workspace/. What am I doing wrong?

I also tried using dockerfile:, but also with the same results: always relative to /github/workspace.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (5 by maintainers)

github_iconTop GitHub Comments

13reactions
yordiscommented, May 28, 2020

I have the following

name: "Release"

on:
  push:
    branches:
      - "production"

jobs:
  publish_docker_image:
    runs-on: ubuntu-latest
    name: Publish docker image
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - name: Publish image
        uses: docker/build-push-action@v1
        with:
          registry: docker.pkg.github.com
          username: $GITHUB_ACTOR
          password: ${{ secrets.GITHUB_TOKEN }}
          repository: org/repo/name
          tag_with_ref: true
          tag_with_sha: true

And it works.

Make sure you have a Dockerfile in the root of the project, double-check that.

11reactions
guumastercommented, Nov 3, 2020

We have this same issue in our workflow. And I think the documentation is not entirely clear. If you have to specify a context path, be sure to add a step with the check out action.

# This Checkout is necessary when using a context in docker/build-push-action
- name: Checkout
  uses: actions/checkout@v2
....
- uses: docker/build-push-action@v2
  with:
    context: ./path/to/context
    file: ./path/to/context/Dockerfile
    tags: docker/image/name:latest
Read more comments on GitHub >

github_iconTop Results From Across the Web

Best practices for writing Dockerfiles - Docker Documentation
Best practices for writing Dockerfiles. This document covers recommended best practices and methods for building efficient images.
Read more >
How do I build a dockerfile if the name of the ... - Stack Overflow
The last parameter to docker build is the build path, ... No files are created in the process, no source is changed. ......
Read more >
Build an Image - Specify Dockerfile Location · Codefresh | Docs
Sometimes you have a project where the Dockerfile is not in the root folder of the ... The dockerfile property of the build...
Read more >
Customize the Docker extension - Visual Studio Code
All common features of Visual Studio Code tasks (for example, ... A Node.js based Docker image with no specific platform options can just...
Read more >
docker-build - Build a new image from the source code at PATH
The build is run by the Docker daemon, not by the CLI, so the whole context must be ... OPTIONS. -f, --file=PATH/Dockerfile Path...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found