Skip to content

Docker deployment of tidal-dl-ng #341

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
53 changes: 53 additions & 0 deletions Dockerfile
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid value repetition, like /home/appuser, appuser etc. and use variables instead (https://docs.docker.com/build/building/variables/)

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Official python 3.12 container image
FROM python:3.12-slim-bookworm


# Environment variables

# Name of the user that will be created
ENV USER_NAME="appuser"

# Name of the group in which the user will be added
ENV GROUP_NAME="users"

# Created user's ID
ENV UID="1000"

# User's home path
ENV HOME_PATH="/home/appuser"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please still avoid value repetitions. Here: appuser


# User's music directory
ENV MUSIC_PATH="${HOME_PATH}/music"



# Set the working directory in the container to /app
WORKDIR /app

# Updating repos
RUN apt update

# Installing ffmpeg for tidal-dl-ng from apt
RUN apt install -y ffmpeg

# Installing tidal-dl-ng from pip
RUN pip install --upgrade tidal-dl-ng

# Creating a user named USER_NAME belonging to group GROUP_NAME along with its home directory
RUN useradd -m -u ${UID} -g ${GROUP_NAME} ${USER_NAME}

# As USER_NAME :
USER ${USER_NAME}

# Creating music folder
RUN mkdir -p ${MUSIC_PATH}

# Configuring ffmpeg and download path for tidal-dl-ng
RUN tidal-dl-ng cfg path_binary_ffmpeg $(which ffmpeg)
RUN tidal-dl-ng cfg download_base_path ${MUSIC_PATH}

# Working directory is appuser's home
WORKDIR ${HOME_PATH}

# Default command if none provided is bash shell
CMD ["/bin/bash"]
31 changes: 31 additions & 0 deletions README.md
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would definitely make sense to combine the two docker sections into one, otherwise it is confusing for non skilled users. What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think making Docker its own section is best ? I'm afraid that the README.md would be repetitive with: pip installation then pip usage then docker installation then docker usage. If you have an idea on how to arrange better the README.md, please let me know, I will take those changes into account.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ If you like this projects and want to support it, feel free to buy me a coffee

## 💻 Installation / Upgrade


### 🐍 Installing with pip
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A blank is missing after ###.


**Requirements**: Python == 3.12 (other versions might work but are not tested!)

```bash
Expand All @@ -50,8 +53,19 @@ pip install --upgrade tidal-dl-ng
pip install --upgrade tidal-dl-ng[gui]
```

### 🐋 Building the Docker image
**Requirements**: Docker == 27.5.0 (other verions might work but are not tested!)
All you need is the ```Dockerfile``` file from this repository and be in the same directory as it.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you state this, if this file is already there?

To build the image using ```docker build``` command:
```bash
docker build -t <container-image-name> .
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace <container-image-name> with a suitable name to avoid further errors by the user.

```
You can give any name you want to the container. The Dockerfile should be easily modified to fit your needs but works great as is.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a predefined name, you can omit this sentence. Let's keep this readme tight.



## ⌨️ Usage

### 🐍 Using pip
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is misleading. Nobody is using pip here.

You can use the command line (CLI) version to download media by URL:

```bash
Expand Down Expand Up @@ -82,6 +96,23 @@ tidal-dl-ng gui
If you like to have the GUI version only as a binary, have a look at the
[release page](https://github.com/exislow/tidal-dl-ng/releases) and download the correct version for your platform.

### 🐋 Using the Docker image

Simply create a music and config folders to mount to the container you will create, then run :

```bash

docker run -v "/path/to/host/music/folder/:/home/appuser/music" -v "/path/to/host/config/dir/:/home/appuser/.config/tidal_dl_ng/" -it <container-image-name>:latest tdn <command>

```

This command will also create two files to store your ```settings.json``` as well as your ```token.json``` when connected to Tidal.

⚠️ The folder from the host that you map in the container must exist beforehand since if Docker creates it, it might be owned by ```root``` and tidal-dl-ng **will not have the rights** to write in this folder ⚠️

💡 You can also run a bash shell if you want to tinker in the container. Nano and ffmpeg are installed and the ffmpeg path is preconfigured in the ```settings.json```.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to map the config directory also to a local directory instead only to have it within the Docker container?

Currently, the Docker image does not support the GUI version.

## 🧁 Features

- Download tracks, videos, albums, playlists, your favorites etc.
Expand Down