Actual behavior
I would like to build an image with the multi stage mechanism.
Expected behavior
It fails with kaniko but works with docker build.
Suggestion
Keep the same timestamp (at least mtime) during the copy of artifacts.
To Reproduce
Steps to reproduce the behavior:
Create the following Dockerfile
FROM debian:bullseye-slim as builder
RUN apt update && \
apt install -yq wget gcc make libpcre3-dev libssl-dev zlib1g-dev
RUN cd /tmp/ && \
wget https://nginx.org/download/nginx-1.14.2.tar.gz && \
tar xfz nginx-1.14.2.tar.gz && \
mv nginx-1.14.2 nginx
RUN cd /tmp/nginx && \
bash ./configure && \
make -j $(nproc)
RUN stat $(find /tmp/nginx|grep ngx_http_postpone_filter_module)
FROM debian:bullseye-slim
COPY --from=builder /tmp/nginx /tmp/nginx
RUN apt update && \
apt install -yq make
RUN stat $(find /tmp/nginx|grep ngx_http_postpone_filter_module)
RUN cd /tmp/nginx && \
make install
Build the image with docker build : docker build -t test-docker:01 .. The image is built. The timestamp of the files before and after the copy.
Therefore, make in verbose mode shows that no rebuild is necessary :
(...)
Prerequisite 'src/os/unix/ngx_linux.h' is older than target 'objs/src/core/nginx.o'.
Prerequisite 'src/core/ngx_regex.h' is older than target 'objs/src/core/nginx.o'.
Prerequisite 'objs/ngx_auto_config.h' is older than target 'objs/src/core/nginx.o'.
Prerequisite 'src/core/nginx.c' is older than target 'objs/src/core/nginx.o'.
No need to remake target 'objs/src/core/nginx.o'
Build the image with kaniko : docker run -v $PWD:/workspace -v ~/.docker/config.json:/kaniko/.docker/config.json:ro gcr.io/kaniko-project/executor:latest --no-push --destination nginx-test-kaniko:01 --context nginx --dockerfile ./Dockerfile
Result (end of the build) the make install commands tries to rebuild the binaries.
Birth: 2022-01-26 08:27:32.722525622 +0000
INFO[2022-01-26T08:27:41Z] Taking snapshot of full filesystem...
INFO[2022-01-26T08:27:41Z] No files were changed, appending empty layer to config. No layer added to image.
INFO[2022-01-26T08:27:41Z] RUN cd /tmp/nginx && make install
INFO[2022-01-26T08:27:41Z] cmd: /bin/sh
INFO[2022-01-26T08:27:41Z] args: [-c cd /tmp/nginx && make install]
INFO[2022-01-26T08:27:41Z] Running: [/bin/sh -c cd /tmp/nginx && make install]
make -f objs/Makefile install
make[1]: Entering directory '/tmp/nginx'
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
-o objs/src/core/nginx.o \
src/core/nginx.c
make[1]: Leaving directory '/tmp/nginx'
make[1]: cc: No such file or directory
make[1]: *** [objs/Makefile:361: objs/src/core/nginx.o] Error 127
make: *** [Makefile:11: install] Error 2
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 2
Therefore, make in verbose mode shows that the rebuild is necessary :
(...)
Prerequisite 'src/os/unix/ngx_linux.h' is newer than target 'objs/src/core/nginx.o'.
Prerequisite 'src/core/ngx_regex.h' is newer than target 'objs/src/core/nginx.o'.
Prerequisite 'objs/ngx_auto_config.h' is older than target 'objs/src/core/nginx.o'.
Prerequisite 'src/core/nginx.c' is newer than target 'objs/src/core/nginx.o'.
Must remake target 'objs/src/core/nginx.o'.
Triage Notes for the Maintainers
Description
Yes/No
Please check if this a new feature you are proposing
- [X]
Please check if the build works in docker but not in kaniko
- [X]
Please check if this error is seen when you use --cache flag
- [ ]
Please check if your dockerfile is a multistage dockerfile
Actual behavior I would like to build an image with the multi stage mechanism.
Expected behavior It fails with
kaniko
but works withdocker build
.Suggestion Keep the same timestamp (at least mtime) during the copy of artifacts.
To Reproduce Steps to reproduce the behavior:
Dockerfile
docker build
:docker build -t test-docker:01 .
. The image is built. The timestamp of the files before and after the copy.Timestamp before copy (for a given file)
make
in verbose mode shows that no rebuild is necessary :kaniko
:docker run -v $PWD:/workspace -v ~/.docker/config.json:/kaniko/.docker/config.json:ro gcr.io/kaniko-project/executor:latest --no-push --destination nginx-test-kaniko:01 --context nginx --dockerfile ./Dockerfile
make install
commands tries to rebuild the binaries.make
in verbose mode shows that the rebuild is necessary :Triage Notes for the Maintainers
--cache
flag