Git Product home page Git Product logo

Comments (9)

mr-smithers-excellent avatar mr-smithers-excellent commented on September 28, 2024 2

@eevers-avisi - great news! This has been merged in. Make sure you're using v3 of this action in your workflow yaml.

FYI @techpool - working directory support has been officially added in v3.

from docker-build-push.

mr-smithers-excellent avatar mr-smithers-excellent commented on September 28, 2024 1

@eevers-avisi - I've been able to get this working on a branch with a new optional directory input. Can you give the below example a try and let me know if it works for your purposes? Note that if a standard Dockerfile already exists in the working directory, you won't have to specify it.

- uses: mr-smithers-excellent/docker-build-push@add-build-dir
  with:
    image: 'mrsmithers/hello-world'
    tag: 'latest'
    registry: 'docker.io'
    dockerfile: 'working-dir/Dockerfile.dir'
    directory: 'working-dir'
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}

from docker-build-push.

mr-smithers-excellent avatar mr-smithers-excellent commented on September 28, 2024 1

@eevers-avisi - I've updated the branch to use the directory input directly in the docker build command instead of using cd. For instance, if you pass working-dir and Dockerfile.root, it will now produce a build command that looks like:

docker build -t your-image:tag -f Dockerfile.root working-dir

Can you give this another try and let me know? If it doesn't work, if you could let me know the project structure you're working with, I can try to emulate on my side. Thanks!

from docker-build-push.

eevers-avisi avatar eevers-avisi commented on September 28, 2024 1

@mr-smithers-excellent It's working correctly right now!

If still needed for further optimising this enhancement, this is the structure of our project. The goals is to build a Docker image using the Dockerfile.subdir (and other files) inside subdirectory. Which is succesfully working with the latest version in @add-build-dir:

|-- Dockerfile.root
|-- subdirectory
    |-- Dockerfile.subdir

from docker-build-push.

eevers-avisi avatar eevers-avisi commented on September 28, 2024

I just saw your reaction on the following PR: #8

You said that by setting the working directory you should also achieve this. I did also try to do that before creating this issue. Unfortunately this didn't work.
image

from docker-build-push.

mr-smithers-excellent avatar mr-smithers-excellent commented on September 28, 2024

Hi @eevers-avisi - thanks for the feedback. Upon further research, it looks like you can't use working-directory in conjunction with uses, only with run. So I'll need to make some changes to get this working. Would something like this fit your use case?

    - uses: mr-smithers-excellent/docker-build-push@v3
      with:
        image: 'owner/image-name'
        tag: 'latest'
        registry: 'docker.io'
        dockerfile: '../Dockerfile' # assuming Dockerfile is at root
        directory: 'dir-name' # if running the build outside project root
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}

from docker-build-push.

eevers-avisi avatar eevers-avisi commented on September 28, 2024

@mr-smithers-excellent Yes, your example would fit my use case

from docker-build-push.

eevers-avisi avatar eevers-avisi commented on September 28, 2024

I tried to use your example and fit in into our project. Unfortunately it still doesn't work for me. I did specify the directory containing the Dockerfile and other needed files with the new directory input. Also I did have to specify the Dockerfile because it took the Dockerfile in the root of our project if I didn't. It seems that the COPY steps in the Dockerfile are still trying to fetch the files from the root of our project, instead of from the specified directory. Also the logging shows that the build command still ends with a . instead of the passed directory.

from docker-build-push.

mr-smithers-excellent avatar mr-smithers-excellent commented on September 28, 2024

Can you give me an overview of what your project structure looks like?

from docker-build-push.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.