grammarly/rocker

EXPORT should never fail with rsync: mkdir "/.rocker_exports/usr/lib/x86_64-linux-gnu" failed: No such file or directory (2)

Closed this issue · 3 comments

I want to build a scratch container using something like this:

FROM ubuntu:16.04
RUN apt-get update &&
    apt-get upgrade -y < /dev/null && \
    apt-get install -y bind9 libjson-c2 && \
    apt-get clean && \
    mkdir -p /var/named/data && \
    chown -R bind:bind /var/named
# Grab the binary and all libraries reported by ldd /usr/sbin/named
EXPORT /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu
EXPORT /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu
EXPORT /lib64/ /lib64
EXPORT /var/named/ /var/named
EXPORT /usr/sbin/named /app/

FROM scratch
IMPORT /                # import the binaries
COPY root.bind9 /       # import our configs
EXPOSE 53/udp 953 8053
ENTRYPOINT ["/app/named", "-g", "-u", "bind"]

However it fails with

INFO[0000] EXPORT /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu
INFO[0000] | Not cached
INFO[0000] | Create container: rocker_exports_507f7e98a72a4dd1a3b2a8d9 for exports
INFO[0000] | Using exports container rocker_exports_507f7e98a72a4dd1a3b2a8d9
INFO[0000] | Created container 2edf93e712ba (image sha256:8efb7)
INFO[0000] | Running in 2edf93e712ba: /opt/rsync/bin/rsync -a --delete-during /usr/lib/x86_64-linux-gnu/ /.rocker_exports/usr/lib/x86_64-linux-gnu
rsync: mkdir "/.rocker_exports/usr/lib/x86_64-linux-gnu" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(656) [Receiver=3.1.1]

This makes sense since the /.rocker_exports/usr/lib/x86_64-linux-gnu directory doesn't yet exist. There are a number of solutions to this outlined nicely at http://stackoverflow.com/a/22908437/538507

I think the Right Way to solve this is using rsync --relative. For example, EXPORT /usr/lib/x86_64-linux-gnu would parse into something like

rsync -a --delete-during --relative /usr/lib/x86_64-linux-gnu/ /.rocker_exports/

Which would create the directory structure under .rocker_exports.

Hi.
--relative flag didn't help, because it didn't use mkdir -p, so we should do mkdir -p in the grammarly rsync image.
@ybogdanov or @diunko should decide to update Grammarly's rsync image to support that.

Now you can use busybox image (+1MB to size compared with scratch) and mkdir.

FROM ubuntu:16.04
EXPORT /usr/lib/x86_64-linux-gnu/ usr_lib_x86_64-linux-gnu/

FROM busybox
RUN mkdir -p /usr/lib/x86_64-linux-gnu
IMPORT usr_lib_x86_64-linux-gnu /usr/lib/x86_64-linux-gnu

BTW, just for prove my PoW I do test with rsync -R

INFO[0000] | Running in 893a72857af6: /opt/rsync/bin/rsync -a -R --delete-during /usr/lib/x86_64-linux-gnu/ /.rocker_exports/usr/lib/x86_64-linux-gnu
rsync: mkdir "/.rocker_exports/usr/lib/x86_64-linux-gnu" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(656) [Receiver=3.1.1]

But we should use rsync -R in IMPORT /section

Thanks for reporting. Unfortunately, we are discontinuing this project. See the notice here: https://github.com/grammarly/rocker/blob/master/README.md

Closing this issue as we are not able to address it. Sorry.