rules_docker
rules_docker copied to clipboard
container_image ignores changes of directories containing static files
🐞 bug report
Affected Rule
The issue is caused by the rule: `container_image`Is this a regression?
Not sure we didn't notice that beforeDescription
If one of the elements of the attributes `files` is a directory of static files, changing, adding or removing files to that directory does not trigger the creation of a new tar and if the previous one exists, it gets loaded as a layer of the docker image.🔬 Minimal Reproduction
Resource directory containing static files
➜ sfdc-bazel git:(W-11689258-java-docker) ✗ ls -la bazel-sfdc-bazel/projects/services/examples/shipping/shipping-scone/resources
total 24
drwxr-xr-x 5 fmangione staff 160 21 Sep 12:32 .
drwxr-xr-x 6 fmangione staff 192 21 Sep 12:29 ..
-rw-r--r-- 1 fmangione staff 1 21 Sep 11:58 foo.md
-rw-r--r-- 1 fmangione staff 10 21 Sep 12:21 foo1.md
-rw-r--r-- 1 fmangione staff 1 21 Sep 11:58 foo2.md
Calling container_image with this way:
container_image({"name": "docker_image", "visibility": None, "base": "@docker_java_base//image", "user": "sfdc-bazel", "tags": ["deployment.sam_app_name=shipping-test", "deployment.sam_container_name=shipping-pod", "deployment.sam_team=Scone", "local"], "labels": {"maintainer": "[email protected]"}, "directory": "/home/sfdc-bazel", "workdir": "/home/sfdc-bazel", "env": {"JAVA_OPTS": "-Denvsysprop=1", "MAIN_ARGS": "envarg1=1"}, "tars": ["//tools/jdk:sfdc-linux-docker"], "files": ["resources", ":shipping-scone.jar", ":docker_imageentrypoint_gen"], "entrypoint": ["/home/sfdc-bazel/docker_image-entrypoint.sh"]})
Output is:
Target //projects/services/examples/shipping/shipping-scone:docker_image up-to-date:
bazel-out/darwin-fastbuild-ST-9e3a93240a9e/bin/projects/services/examples/shipping/shipping-scone/docker_image-layer.tar
INFO: Elapsed time: 0.463s, Critical Path: 0.06s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
Loaded image ID: sha256:4fd94bd5dd28abd753e6a2c747346ec4fd6aa9cfd9f0a8adc8ae6d61aea17076
Tagging 4fd94bd5dd28abd753e6a2c747346ec4fd6aa9cfd9f0a8adc8ae6d61aea17076 as bazel/projects/services/examples/shipping/shipping-scone:docker_image
The content of the tar file is:
tar -tvf bazel-out/darwin-fastbuild-ST-9e3a93240a9e/bin/projects/services/examples/shipping/shipping-scone/docker_image-layer.tar | grep foo
-r-xr-xr-x 0 0 0 1 1 Jan 1970 ./home/sfdc-bazel/resources/foo.md
-r-xr-xr-x 0 0 0 10 1 Jan 1970 ./home/sfdc-bazel/resources/foo1.md
-r-xr-xr-x 0 0 0 1 1 Jan 1970 ./home/sfdc-bazel/resources/foo2.md
Removing foo2.md in the resources directory won't trigger a new tar that would keep containing the same content as before:
container_image({"name": "docker_image", "visibility": None, "base": "@docker_java_base//image", "user": "sfdc-bazel", "tags": ["deployment.sam_app_name=shipping-test", "deployment.sam_container_name=shipping-pod", "deployment.sam_team=Scone", "local"], "labels": {"maintainer": "[email protected]"}, "directory": "/home/sfdc-bazel", "workdir": "/home/sfdc-bazel", "env": {"JAVA_OPTS": "-Denvsysprop=1", "MAIN_ARGS": "envarg1=1"}, "tars": ["//tools/jdk:sfdc-linux-docker"], "files": ["resources", ":shipping-scone.jar", ":docker_imageentrypoint_gen"], "entrypoint": ["/home/sfdc-bazel/docker_image-entrypoint.sh"]})
tar -tvf bazel-out/darwin-fastbuild-ST-9e3a93240a9e/bin/projects/services/examples/shipping/shipping-scone/docker_image-layer.tar | grep foo
-r-xr-xr-x 0 0 0 1 1 Jan 1970 ./home/sfdc-bazel/resources/foo.md
-r-xr-xr-x 0 0 0 10 1 Jan 1970 ./home/sfdc-bazel/resources/foo1.md
-r-xr-xr-x 0 0 0 1 1 Jan 1970 ./home/sfdc-bazel/resources/foo2.md
Same thing happens even adding or changing files in that directory.
🔥 Exception or Error
🌍 Your Environment
Operating System:
macOS Monterey v 12.5.1
Output of bazel version:
bazel 5.1.1
Rules_docker version:
v0.25.0
Anything else relevant?