I'm trying to build chromium v8
inside a container as part of another program's build chain, and one of the binary build tools crashes because it's trying to rename/move files across the filesystem boundary that overlayfs
creates for container layers.
I've opened a bug with the build tool hoping there's a way it can gracefully handle overlayfs
without potentially introducing a lot of burden to the chromium team, but in the best case scenario it's going to be quite a while before that's helpful.
I have some workarounds in the meantime:
- running everything that touches those files in the same layer, which means they end up being re-downloaded every time (many GBs), which is a non-starter for some maintainers on the project I'm contributing to who are on metered connections.
- copying to temp, deleting original, then moving back so it's owned by the layer, which will double the size on disk, and make the build much slower
Both of the options are kind of awful.
So that's why I'm curious if there's a way to just tell Docker or overlayfs
to remove or ignore the boundaries between a few layers, or to tell them to move the files into the current layer.
For example:
Moving (even after a copy) is crossing a layer boundary and and can fail with XDEV errors.
COPY ./some-file ./some-file
RUN mv ./some-file ./some-renamed-file
I can get around this, by copying it internal to a layer, so it's owned by that layer:
COPY ./some-file ./some-temporary-file-name
RUN cp ./some-temporary-file-name ./the-real-file-name \
&& rm ./some-temporary-file-name
This is significantly more problematic and resource intesive when you need to do this with huge directories of source files, and the failure is part of an external program, where the specific files that will need to be moved are non-deterministic (files named with random hashes)
RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
WORKDIR /v8-temp
RUN fetch v8 \
&& mkdir /v8
# I have to duplicate the entire working directory
# since I can't know what the tool will need to move
WORKDIR /v8
RUN cp -r /v8-temp /v8 \
&& rm -rf /v8-temp \
&& gclient sync
# and if I don't clean up the image through other means
# I also have to wait for the old source files to be deleted,
# increasing the build time or image size of the result.