simulot / immich-go

An alternative to the immich-CLI command that doesn't depend on nodejs installation. It tries its best for importing google photos takeout archives.
GNU Affero General Public License v3.0
1.18k stars 35 forks source link

feat: support build docker image #306

Closed pkking closed 3 days ago

pkking commented 2 weeks ago

This PR want to support building docker image for this awesome project, maybe more steps can be done like publish package with github action :)

PS: will be happy to make more contributions!

pkking commented 2 weeks ago

This is cool. Thank you. The initial idea of immich-go was to not bother tandom users with npm, docker, etc... :-)

But apparently there is an use case for docker...

Do you know how to publish the package with github actions?

Will try to add a workflow file later, ref: https://github.com/pkking/copr_docker/blob/main/.github/workflows/keygen-signd-publish.yml#L48-L110

pkking commented 2 weeks ago

@simulot This pr contains a new workflow that can publish a docker image to docker hub && ghcr registry, you just need to add two github action secret DOCKERHUB_USERNAME and DOCKERHUB_TOKEN

Here's the newest image i pushed from the forked repo action

simulot commented 2 weeks ago

I have more questions about this? Can we have discussion on Discord or by email?

pkking commented 2 weeks ago

I have more questions about this? Can we have discussion on Discord or by email?

@simulot Sure thing, discord id: lcr1221 and TZ: GMT+8, if not available, can email me using the address from the PR commit :)

erkexzcx commented 1 week ago

Why would someone need Docker image for this?. :thinking:

Also, why would you use anything other than scratch as base image? My example (that also needs ca-certificates for Golang): https://github.com/erkexzcx/valetudopng/blob/main/Dockerfile

erkexzcx commented 1 week ago

@simulot you can also use ghcr.io (GitHub's registry) instead of Dockerhub.

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
simulot commented 1 week ago

@erkexzcx Thanks, I prefer this option.

Is it possible to leverage github actions to generate binaries for all platforms? triggered by tagging the main branch?

erkexzcx commented 1 week ago

@pkking what is the benefit of Docker to begin with? Here is why I believe Docker images are not needed:

  1. This app does not run as a service/daemon (unless I am missing something?)
  2. This app has zero dependencies, literally a single statically linked binary.
  3. Putting this binary into a container would end up with...the same binary, just with extra steps. :shrug:
pkking commented 1 week ago

Why would someone need Docker image for this?. 🤔

Also, why would you use anything other than scratch as base image? My example (that also needs ca-certificates for Golang): https://github.com/erkexzcx/valetudopng/blob/main/Dockerfile

Hi @erkexzcx, my use case is i want to run immich-go in cronjob, each time the job scheduled, will need to upgrade immich and immich-go both firstly and i didnt find a one click upgrade script except using docker, so that's it :)

pkking commented 1 week ago

@simulot you can also use ghcr.io (GitHub's registry) instead of Dockerhub.

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

https://github.com/simulot/immich-go/pull/306/files#diff-551d1fcf87f78cc3bc18a7b332a4dc5d8773a512062df881c5aba28a6f5c48d7R47-R53 this PR will push the image to both dockerhub and ghcr

simulot commented 1 week ago

Hi @erkexzcx, my use case is i want to run immich-go in cronjob, each time the job scheduled, will need to upgrade immich and immich-go both firstly and i didnt find a one click upgrade script except using docker, so that's it :)

That's legit. But this will put the maintenance and the support for this release on me. I don't master the docker environnement enough for providing a good support.

What if you release the docker image on your own, synchronized with immich-go release? I'll add a section in the readme file that points to your repo?

erkexzcx commented 1 week ago

my use case is i want to run immich-go in cronjob, each time the job scheduled

Instead of using Docker....

0 3 * * * docker run -it simulot/immich-go <args>

you can totally use binary just in a same way...

0 3 * * * /usr/local/bin/immich-go <args>

@simulot not that it would bring more maintenance, but there is barely any benefit of providing Docker image for a tool like this. Imagine this would have been nodejs project - totally makes sense to provide Docker image as user wouldn't need to install nodejs and with Docker you can ensure that user uses the right nodejs version, the right configuration, you provide isolated and consistent environment etc. With Golang, it's just a single binary, no external deps and personally I don't see any reason to provide Docker image.

Certain services, including the ones that I (barelly) maintain, they are running as services/daemons and even tho they can be used as regular binaries, I also provide Docker images because it's way more convenient to have all your services at your home server to be running under a single "roof" which is Docker service. But again - those are services/daemons that run 24/7, while this tool is supposed to be ran once and that's it.

simulot commented 1 week ago

@erkexzcx your point is valid. I have started immich-go exactly because I wouldn't install node.js and all other dependencies on my laptop. A golang program is a perfect fit for that need.

Some users are using immich-go not for the google photos import but for synchronise regularly immich with another source of photos. They run immich-go as a cron task. Certainly a niche usage. Immich-go is open source, and every one can contribute. So why not. @pkking can maintain the image on is own.

pkking commented 1 week ago

my use case is i want to run immich-go in cronjob, each time the job scheduled

Instead of using Docker....

0 3 * * * docker run -it simulot/immich-go <args>

you can totally use binary just in a same way...

0 3 * * * /usr/local/bin/immich-go <args>

@simulot not that it would bring more maintenance, but there is barely any benefit of providing Docker image for a tool like this. Imagine this would have been nodejs project - totally makes sense to provide Docker image as user wouldn't need to install nodejs and with Docker you can ensure that user uses the right nodejs version, the right configuration, you provide isolated and consistent environment etc. With Golang, it's just a single binary, no external deps and personally I don't see any reason to provide Docker image.

Certain services, including the ones that I (barelly) maintain, they are running as services/daemons and even tho they can be used as regular binaries, I also provide Docker images because it's way more convenient to have all your services at your home server to be running under a single "roof" which is Docker service. But again - those are services/daemons that run 24/7, while this tool is supposed to be ran once and that's it.

@erkexzcx Thats right, so thats an XY problem, the actual reason i want to use docker is because i want to upgrade immich-go to latest version before each cronjob started, for immich-go in docker, just

* * * * * sync_photos.sh

then

cat sync_photos.sh
#!/bin/bash
docker rmi  simulot/immich-go
docker run -t --rm  simulot/immich-go upload <path to upload>

Without a docker image, i can't find a way to do this, if anyone provided a one Liner script to achive this, that would be The One as well :)

And yes, @simulot i'd like maintain the docker and github actions stuff is this PR get merged

erkexzcx commented 1 week ago

@erkexzcx Thats right, so thats an XY problem, the actual reason i want to use docker is because i want to upgrade immich-go to latest version before each cronjob started, for immich-go in docker, just

* * * * * sync_photos.sh

then

cat sync_photos.sh
#!/bin/bash
docker rmi  simulot/immich-go
docker run -t --rm  simulot/immich-go upload <path to upload>

Without a docker image, i can't find a way to do this, if anyone provided a one Liner script to achive this, that would be The One as well :)

Don't take me for serious here, but it is more than doable... :sweat_smile:

#!/bin/bash

# Exit on any error
set -e

# Find latest version
latest=$(curl -s https://api.github.com/repos/simulot/immich-go/releases/latest | grep tag_name | sed 's/.*"tag_name": "\(.*\)",/\1/')

# Download latest version
curl -L -o /tmp/immich-go_Linux_x86_64.tar.gz "https://github.com/simulot/immich-go/releases/download/$latest/immich-go_Linux_x86_64.tar.gz"

# Extract archive to /tmp
tar -xf /tmp/immich-go_Linux_x86_64.tar.gz -C /tmp/

# Copy binary to /usr/local/bin
sudo cp /tmp/immich-go /usr/local/bin

# Do what you need
immich-go --version
simulot commented 1 week ago

Do what you need

immich-go --version

Got it