darakian / ddh

A fast duplicate file finder
Other
452 stars 18 forks source link

Add Dockerfile #21

Closed MrSaints closed 4 years ago

MrSaints commented 4 years ago

This Dockerfile uses a multi-stage Docker build to produce a relatively minimal image for the ddh tool.

Once built, it can be used like so:

docker run --rm \
    -v "$(pwd):/target/:ro" \
    -v "/my-host-results-dir/:/results/" \
    <ddh image> \
    ddh . --output /results/results_1.txt

This way, you can safely check for duplicates in your current working directory (marked as read-only), and write results to a separate directory (e.g. /my-host-results-dir/ in the example above).

For users without Rust installed on their machines, this may be an easier execution option that is relatively platform agnostic.

TODO:

264nm commented 4 years ago

Why not a musl statically linked binary just out of curiousity? I’ve done that before and deployed a container that was literally just FROM scratch + config for the application. Gives the benefit of a portable binary even without the container.

MrSaints commented 4 years ago

@264nm From my somewhat limited experience, I was not able to get the statically linked binary from musl to work across architecture, e.g. on RaspberryPi ARM. Hence, going for the slightly bulkier option that I know will work in most cases. Though, nothing is really stopping us from shipping multiple tagged Docker images if people prefer something lighter weight.

darakian commented 4 years ago

Hey, thanks for the PR, but I'm a bit reluctant to add what I consider to be deploy specific code to this repo. I'm curious what the use case you have is though; is rust not available on raspberry pis?

MrSaints commented 4 years ago

Hey, thanks for the PR, but I'm a bit reluctant to add what I consider to be deploy specific code to this repo.

Fair enough, and totally understandable 👍 I'm already using it, but I figured I make a PR in case you might find it useful.

I'm curious what the use case you have is though; is rust not available on raspberry pis?

It is possible to install it. It is just that in some cases, if you are not working directly with Rust, you'd probably won't have it installed or have any need to have it installed.

In my case, I already have Docker installed so that's the next easy usage path. I could also use a static binary, but there isn't one released. And I think there's also the relative peace of mind of being able to run the checker in read-only mode.

darakian commented 4 years ago

Fair enough, and totally understandable 👍 I'm already using it, but I figured I make a PR in case you might find it useful.

Thanks for the consideration :)

It is possible to install it. It is just that in some cases, if you are not working directly with Rust, you'd probably won't have it installed or have any need to have it installed.

To that point it seems like you're trading off installing rust for installing docker though.

In my case, I already have Docker installed so that's the next easy usage path. I could also use a static binary, but there isn't one released. And I think there's also the relative peace of mind of being able to run the checker in read-only mode.

I could make more binaries available I guess. To be honest the windows binary is only there because (in general) windows users tend to be less familiar with code compilation. The peace of mind of running in read only mode I agree with.

As a side tangent you might look into rust cross compilation. It's fairly straight forward and might serve 90% of what you're after. https://github.com/japaric/rust-cross