This works:
# note: cache .cache/go-build across docker builds
RUN --mount=type=tmpfs,target=/home/myuser/.cache \
pacman -S --needed --noconfirm go && \
su - myuser -c " \
my GO build goes here" && \
pacman -Rcsn --noconfirm go
in the sense that the non-root user myuser
is able to write to the tmpfs mount and the GO build completes successfully.
But if I prepend to the above, another instruction in the dockerfile which mounts the same tmpfs, such as
RUN --mount=type=tmpfs,target=/home/myuser/.cache \
ls -Al
then surprisingly the GO build fails with
#18 42.37 failed to initialize build cache at /home/myuser/.cache/go-build: mkdir /home/myuser/.cache/go-build: permission denied
It appears as though the tmpfs mount does not have proper permissions the 2nd time it is mounted. Anyone experience the same? is it a bug?