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

Build from dockerfile does not recreate image after changes in dockerfile or its context. #547

Open
2 tasks done
neworld opened this issue Jun 15, 2024 · 5 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@neworld
Copy link

neworld commented Jun 15, 2024

⚠️ Please verify that this bug has NOT been reported before.

  • I checked and didn't find similar issue

🛡️ Security Policy

Description

Images are not rebuilt upon deploy or update, if dockerfile was changed. However, I am not sure if this problem could be simply fixed without causing a negative effect on stacks without dockerfiles. In this case a button forcing --build is good enough solution

👟 Reproduction steps

Let's assume having such compose file:

services:
  my-dockerfile:
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped

Docker file itself can be empty like:

FROM alpine:latest
  1. Deploy service
  2. change docker file
  3. deploy service

👀 Expected behavior

The image should rebuilt like using docker-compose up --build -d

😓 Actual Behavior

Only container recreated like using docker-compose up -d (without --build)

Dockge Version

1.4.2

💻 Operating System and Arch

Debian

🌐 Browser

Chrome

🐋 Docker Version

Docker version 20.10.24+dfsg1, build 297e128

🟩 NodeJS Version

No response

📝 Relevant log output

No response

@neworld neworld added the bug Something isn't working label Jun 15, 2024
@matbgn
Copy link

matbgn commented Aug 13, 2024

Would also vote for an extra button called "build" on the side of the "update" one ;-)

@hg42
Copy link

hg42 commented Aug 14, 2024

I am using dockerfile_inline and have the same problem (surprise :-)).

If there is no image configured, but a build section, update button could automatically build.
No need for an extra button, especially because update does nothing.
deploy should always build in this case.

On my side it's also related to watchtower.
As far as I read, watchtower uses the base image and does not see the changes in the compose file.
This seems to be ok, because I deploy anyways, if I change the compose file.
But if watchtower only downloads the image without applying the dockerfile, this would strip the additional parts from the image and I would need another solution instead of watchtower.
If at some point dockge already does all the basic work, it would be the ideal place to add some scheduling to do regular updates.

@matbgn
Copy link

matbgn commented Aug 14, 2024

My 2 cents on the fact that the update button should also force build image if their were modifications within the build context is that maybe it will not be the behaviour expected but apart from that it seems perfectly OK IMO.

@OneWeekNotice
Copy link

Adding some additional information. If you want update button to automatically re build the image. You can use pull_policy: build

Reference docker compose documentation

Not saying this solves the original ask of potential checking if the dockerfile was modified and forced the rebuild VS doing a rebuild every single time.

Sample:

services:
  my-dockerfile:
    build:
      context: .
      dockerfile: Dockerfile
  pull_policy: build
  restart: unless-stopped

@hg42
Copy link

hg42 commented Aug 15, 2024

thanks for the pointer, I didn't look into pull_policy because I didn't want to pull it :-)

this actually works for me (only the build, not the final goal):

...
  nodered:
    container_name: nodered
    #image: docker.io/nodered/node-red
    pull_policy: build
    build:
      context: .
      dockerfile_inline: |
        FROM docker.io/nodered/node-red:latest
        USER root
        RUN apk add --no-cache chromium
        USER node-red
    ...

the build takes longer for the first time and then runs quite fast (though it's always creating a new image, at least that's what it says).
If I change the dockerfile_inline value, then it takes longer again (e.g. the apk command if I add a package or if I add another RUN line).

And the inline file is shown in green, which is nice.

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

No branches or pull requests

4 participants