muslrust
muslrust copied to clipboard
WORKDIR defaults to /volume -- is this desired?
I'm new to muslrust, and I'm having to use it to compile a binary for the x86_64-unknown-linux-musl target -- one thing I noticed, compared to other containers like rust, is that WORKDIR defaults to /volume. Take this Dockerfile for example:
FROM rust AS build
ADD src src
ADD Cargo.toml Cargo.toml
RUN cargo build --release
FROM public.ecr.aws/lambda/provided:al2
COPY --from=build ./target/release/collector-api main
RUN chmod o+rx main
ENTRYPOINT ["./main"]
This works, however when using muslrust instead of rust to build, I have to specify /volume in the COPY --from=build command:
FROM clux/muslrust:stable AS build
ADD src src
ADD Cargo.toml Cargo.toml
RUN cargo build --release --target x86_64-unknown-linux-musl
FROM public.ecr.aws/lambda/provided:al2
COPY --from=build ./volume/target/x86_64-unknown-linux-musl/release/collector-api ./app
RUN chmod o+rx ./app
ENTRYPOINT ["./app"]
This confused me for quite a while and I only found this out from looking at Docker command history for the container.
Is it intentional to have the working directory as /volume? If so, shouldn't this be documented somewhere like in the README?
Yep, this is a good catch. Thank you.
Long story short; I wasn't actually aware that this could be done in an easier way without some explicit WORKDIR when this was conceived, and it's probably a bit too late to change it at this point (since nobody can reasonably expect to notice breaking changes in docker images between equal, floating tags), so this is probably one for README docs.