Closed idelvall closed 8 months ago
Works for me!
I noticed I'm no longer able to use GET_RUST_CACHE_MOUNTS
. I though maybe it was renamed to SET_CACHE_MOUNTS_ENV
, so I updated my earthly file (see below), but that also does not work. It does not seem to create an artifact.
Maybe I'm missing something?
https://github.com/atomicdata-dev/atomic-server/issues/805
cross-build:
FROM +source
ARG --required TARGET
DO rust+SET_CACHE_MOUNTS_ENV
WITH DOCKER
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE cross build --target $TARGET --release
END
SAVE ARTIFACT ./target/$TARGET/release/atomic-server AS LOCAL artifact/bin/atomic-server-$TARGET
Hi @joepio, given that target
folder is within the mount cache, so you need to copy the output files first to the target layers, so it can be retrieved with SAVE ARTIFACT
later on.
You can use +COPY_OUPUT
target for that purpose: https://github.com/earthly/lib/blob/main/rust/README.md#copy_output
@idelvall I can't get rust+COPY_OUTPUT
to actually copy anything.
Even with DO rust+COPY_OUTPUT --output="*"
my ./target
directory seems completely empty.
Am I missing something?
cross-build:
FROM +source
ARG --required TARGET
DO rust+SET_CACHE_MOUNTS_ENV
WITH DOCKER
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE cross build --target $TARGET --release
END
DO rust+COPY_OUTPUT --output="*"
RUN ./target/$TARGET/release/atomic-server --version
SAVE ARTIFACT ./target/$TARGET/release/atomic-server AS LOCAL artifact/bin/atomic-server-$TARGET
logs: https://cloud.earthly.dev/builds/2227c1db-854b-4b3a-a3d0-ca012c0a9873
That argument is actually a regexp @joepio.
Try starting with --output=".*"
and then making it more specific, so only the files of your interest are copied
Ah yes, thanks!
One step further :)
Adds
+SET_CACHE_MOUNTS_ENV
: that sets two entries in the environment with the code for the cache mounts.+COPY_OUTPUT
: to copy files from the the target mount cache to the image layersThis new approach gives more flexibility, for example to run within a
WITH DOCKER
clause:Example: