You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My application creates files and in my test I check whether the creation was successful or not. with go test everything is fine, but with the containerised build I get the error of read-only file system
I tried it with setting the mount to "bind" FROM base AS unit-test RUN --mount=target=. \ --mount=type=bind,target=/root/.cache/go-build \ go test -v .
but without success.
Any hints for me?
The text was updated successfully, but these errors were encountered:
I had the sme experience as you "read only" - for me it happens only when using docker build and use the mount experimental features in Dockerfile on OSX. I guess you also use a Mac?
For that I rewrote the processes and put the build statements into the Makefile with docker run commands.
Bind mounts in this context mean bind mounting of the build context, not the files directly on the host. Note that the default mount without specifying a type is bind.
By default bind mounts are readonly with the option for read-write but written files are discarded from the final build.
If you want to keep the outputs of tests, you try to output them to somewhere outside of the working directory that you've bind mounted into or you can do a COPY . . instead of the mount=target=..
Old:
FROM base AS unit-test
RUN --mount=target=. \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
mkdir /out && go test -v -coverprofile=/out/cover.out ./...
New:
FROM base AS unit-test
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
mkdir /out && go test -v -coverprofile=/out/cover.out ./...
My application creates files and in my test I check whether the creation was successful or not. with
go test
everything is fine, but with the containerised build I get the error ofread-only file system
I tried it with setting the mount to "bind"
FROM base AS unit-test RUN --mount=target=. \ --mount=type=bind,target=/root/.cache/go-build \ go test -v .
but without success.
Any hints for me?
The text was updated successfully, but these errors were encountered: