casey / intermodal

A command-line utility for BitTorrent torrent file creation, verification, and more
https://imdl.io
Creative Commons Zero v1.0 Universal
487 stars 25 forks source link

feat: add dockerfile #533

Closed rare-magma closed 6 months ago

rare-magma commented 9 months ago

Containerizing intermodal makes it easier to use without installing it.

The docker image can be hosted on ghcr.io and its build automated via github action: https://docs.github.com/en/actions/publishing-packages/publishing-docker-images

The container can then be used like this:

docker run --rm --init --interactive --tty --volume "$(pwd)":/mnt ghcr.io/casey/intermodal torrent show /mnt/example.torrent
rare-magma commented 9 months ago

@casey I've simplified the dockerfile to use the official docker library rust image as the build stage. The drawback with this approach is that any change in the repository invalidates the docker cache and results in a full rebuild. In the end it shouldn't matter if the image is only built once per release.

casey commented 6 months ago

Gotcha, in that case distroless sounds good. I probably won't wind up publishing the docker image myself, I avoid managing package repo packages myself because it's extra work to remember then releasing, so for now let's remove the reference to docker pull ghcr.io/casey/intermodal (since I suppose that would mean I would have to publish it)

rare-magma commented 6 months ago

Gotcha, in that case distroless sounds good. I probably won't wind up publishing the docker image myself, I avoid managing package repo packages myself because it's extra work to remember then releasing, so for now let's remove the reference to docker pull ghcr.io/casey/intermodal (since I suppose that would mean I would have to publish it)

@casey I've removed the reference to ghcr in https://github.com/casey/intermodal/pull/533/commits/e4cf429083a8e0f3c637dabcfd4e61b6ce0c7871

In case you'd like to publish it automatically in the future it can be done easily with a github action as described in https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages

casey commented 6 months ago

Looks good to me! I changed /app to /usr/local/src, which is a well-known location for source files. Also, I removed the AS runtime, since as far as I can tell, it's not necessary to name a layer if it's not referred to in the future. I also added a just recipe to build and run the image using podman. I'm on macos, and podman is nice because it doesn't require root.

casey commented 6 months ago

The build failure is unrelated to this PR. I'll fix it in another PR and then merge this.

casey commented 6 months ago

Blocked on #537.

casey commented 6 months ago

Merged, thanks for the PR!