flother / spreet

Create a spritesheet from a set of SVG images
MIT License
81 stars 4 forks source link

Support docker command line usage #83

Open HarelM opened 3 weeks ago

HarelM commented 3 weeks ago

Hi,

Is it possible to create and publish a docker image to allow running this without any other configuration?

flother commented 3 weeks ago

Ah, that's an interesting question. One of the reasons I wrote Spreet as a single binary was so I wouldn't have to deal with Docker. I do make pre-compiled binaries available for each release if that would be any use to you — see the latest v0.11.0 release for example.

What would you like the image to do, if you could choose? We have a few options, I suppose. It could simply download the latest pre-compiled binary, or it could clone the repo, download the Rust compiler, and build it from source.

What's your use-case? Let me know and we can work out the best approach.

HarelM commented 3 weeks ago

I would like the docker image to simply wrap the binary (This will create a dockerfile that is also a good reference if you want to compile the binary locally). This docker image can get the parameters for the binary to use, and probably mount it to the relevant svg folder. Basically, I don't want to install anything on my machine besides docker to use this tool, either a mac, windows or linux system. so something like docker run --rm -v $(pwd)/icons:/var/data/icons flother/spreet icons my_style would be great.

flother commented 3 weeks ago

OK, I’ll look into this when I get a chance.

So basically the Dockerfile should look something like this:

  1. Use a base image that has the Rust toolchain installed (available on Docker Hub)
  2. Run cargo install spreet@v0.11.0 to install Spreet from crates.io
  3. Set the working directory to /var/data
  4. Make the spreet binary the entry point for the image

And when a new version of Spreet’s released, the CI job would need to tag a new version of the image and push it to a container registry (probably ghcr.io).

HarelM commented 3 weeks ago

Or you can create a two steps docker where you build the binary in the first step and use it in the second step. But otherwise, this is the right direction.