Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simple dockerfile #4831

Merged
merged 3 commits into from
Nov 21, 2023
Merged

add simple dockerfile #4831

merged 3 commits into from
Nov 21, 2023

Conversation

Nitrousoxide
Copy link
Contributor

This adds a simple dockerfile that a user can use to build the project locally on podman or docker. It adds a couple of deps that may be necessary for downloading galleries like ffmpeg and yt-download. If there are additional dep's you think should be added let me know and I can adjust the PR.

If this is accepted I can also add a how-to for running this as you will probably want to mount some local directories for the download location or config files so they can make it back up to the host.

@JSouthGB
Copy link
Contributor

Not criticism, pure curiosity. What advantage does docker have over a python venv?

@Nitrousoxide
Copy link
Contributor Author

Not criticism, pure curiosity. What advantage does docker have over a python venv?

I don't know if either is better per se, but both have their use cases.

  1. Docker/Podman allow you to limit the application's access to just the directories on the host it needs.
  2. The container can be destroyed after use with a docker run --rm flag as part of the run command since this application probably doesn't need to persist. That way you also have a pristine environment on every run.
  3. You don't need to worry about conflicting dependencies since each container uses something like chroot to separate its filesystem from other containers and the host.
  4. If you setup a ci/cd pipeline the user can just download the image rather than having to build locally (though a simple Dockerfile here wouldn't really do that, they can do that seperately. I do for my homelab with it auto-building gallery-dl each morning)
  5. Since docker/podman are run inside a linux vm on MacOS or Windows (with its WSL 2) it simplifies the run environment by making everything consistent for the user.
  6. Runtime dependencies you want have for a single application don't need to be shared by the host OS or every other application. Like here you don't need to have yt-download installed on the hosts $PATH and accessible for every other application..

I'm sure some other stuff too.

Nothing stoping someone from just running the pip install command still. I mean heck, that's what the dockerfile is doing under the hood.

Dockerfile Outdated Show resolved Hide resolved
changed youtube_dl to yt-dlp and combined install line

Co-authored-by: Jouni Järvinen <[email protected]>
Dockerfile Outdated Show resolved Hide resolved
@mikf
Copy link
Owner

mikf commented Nov 20, 2023

There have been two other Dockerfile PRs in the past (#192, #1229) and I rejected them both, but I guess I'll merge this onc because why not.

I can also add a how-to for running this

There are many other resources out there that explain this. Then again, (some) people seem to have the greatest difficulties using a search engine to find information about topics they might need to effectively use gallery-dl, judging from some of the issues opened here.

Co-authored-by: Mike Fährmann <[email protected]>
@Nitrousoxide
Copy link
Contributor Author

There are many other resources out there that explain this. Then again, (some) people seem to have the greatest difficulties using a search engine to find information about topics they might need to effectively use gallery-dl, judging from some of the issues opened here.

Would you like me to add a brief few sentence how-to on how to biuld and generic run command for the readme? Where they would need to mount the host volumes in the container may not be immediately obvious to someone:

-v $HOME/Downloads/:/gallery-dl/
-v $HOME/.config/gallery-dl/gallery-dl.conf:/etc/gallery-dl.conf #import the config file template referenced in the git repo

@mikf
Copy link
Owner

mikf commented Nov 20, 2023

I guess it wouldn't hurt.

@mikf mikf merged commit 0f3a068 into mikf:master Nov 21, 2023
9 checks passed
@Skaronator
Copy link

It would be cool if the Docker Image would be pushed to the GitHub Container Registry.

Currently, I'm using my own image published to GHCR and Docker Hub: https://github.com/Skaronator/docker-gallery-dl

@mikf
Copy link
Owner

mikf commented Dec 1, 2023

I've never really done much with Docker, so who knows if I got this right, but I docker build an image from this Dockerfile and docker push-ed it to GHCR and hub.docker.com:

@mikf
Copy link
Owner

mikf commented Dec 5, 2023

I made an attempt to write a github actions workflow to build a docker image and push it it dockerhub and ghcr when pushing a commit with a version tag. (43ca49c)

The first mistake in it was adding these two lines as on condition, but that's easy enough to fix by simply deleting them.

branches:
- master

The next problem is that it for some reason failed to push to ghcr.

ERROR: failed to push ghcr.io/mikf/gallery-dl:99b76628f7ba66fd19a11c454e23572164b55315: unexpected status from POST request to https://ghcr.io/v2/mikf/gallery-dl/blobs/uploads/: 403 Forbidden

Does anyone have a clue why this didn't work?

@Skaronator
Copy link

Looks like you are using the wrong GitHub token.

https://github.com/Skaronator/docker-gallery-dl/blob/3c62f209d718b9569c62fcbe3404c293e8ea3af9/.github/workflows/release.yaml#L73

https://stackoverflow.com/a/66903734

Additionally, I would recommend that the latest Tag points to the last stable Release and you can use an "edge" or "dev" or "unstable" Tag for every build in the master branch.

mikf added a commit that referenced this pull request Dec 5, 2023
- run only on tagged commits and not on every commit to master
- use the correct github token
@mikf
Copy link
Owner

mikf commented Dec 5, 2023

I hope this fixes it: d1ea60c

I would recommend that the latest Tag points to the last stable Release

That's how it was supposed to work, but I misunderstood how on conditionals work.

"edge" or "dev" or "unstable" Tag

I don't think that's possible with the current Dockerfile since it pulls from PyPI.

@mikf
Copy link
Owner

mikf commented Dec 5, 2023

Looks like you are using the wrong GitHub token.
https://stackoverflow.com/a/66903734

Both are equivalent.
Apparently they are the same:

Wait, so this doesn't actually make a difference?

edit: github.token is also what Danbooru uses

mikf added a commit that referenced this pull request Dec 8, 2023
@mikf mikf added the docker label Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants