Skip to content

Latest commit

 

History

History
141 lines (132 loc) · 8.04 KB

DOCKER.md

File metadata and controls

141 lines (132 loc) · 8.04 KB

YTuner in Docker container

If you can't live without containers and you think that every day without creating a new container is a wasted day, you can also run YTuner in a container.

Assumptions

In my opinion, there is no point in placing cache, config and db with the contents in the container and we should use CacheFolderLocation, ConfigFolderLocation and DBFolderLocation options of ytuner.ini file and point to host resources to remain persistent. Therefore, in this short description I'll focus on this scenario, but of course everyone can choose their own.

Tip: In the description below, I'll use Ubuntu 22.04 LTS as a host, x86_64-linux YTuner binaries and Alpine Linux Docker image to make my container as small as possible.

If you are familiar with building Docker containers, you may want to skip reading further. If not, don't worry and read on.

That's easy

1) Install Docker

Use a well-documented procedure: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

2) Prepare YTuner binaries and configuration

First, let's prepare some host shared volume (i.e. ~/YTuner) and copy your YTuner's config and my_station.ini/yaml files.

ladm@localubuntu20:~$ mkdir YTuner && cd YTuner && mkdir config
ladm@localubuntu20:~/YTuner$ 

Now, let's prepare YTuner-docker directory :

ladm@localubuntu20:~$ mkdir YTuner-docker && cd YTuner-docker
ladm@localubuntu20:~/YTuner-docker$ 

Get YTuner binaries :

ladm@localubuntu20:~/YTuner-docker$ wget https://github.com/coffeegreg/YTuner/releases/download/1.2.2/ytuner-1.2.2-x86_64-linux.zip

or build your own from source.

Extract ytuner and ytuner.ini files only :

ladm@localubuntu20:~/YTuner-docker$ unzip -d x86_64-linux/ ytuner-1.2.2-x86_64-linux.zip ytuner ytuner.ini

Make ytuner executable :

ladm@localubuntu20:~/YTuner-docker$ sudo chmod +x x86_64-linux/ytuner

Edit and change the ytuner.ini file as you wish, but remember to set the following options :

CacheFolderLocation=/app/host-shared
ConfigFolderLocation=/app/host-shared
DBFolderLocation=/app/host-shared

Now prepare the following Dockerfile :

# Start with the Alpine 3.19 Docker image.
FROM alpine:3.19

# Install libc6-compat, required for executables generated by FPC.
RUN apk --no-cache add libc6-compat
# Install sqlite-libs to support [catDB,catMemDB,catPermMemDB] cache types.
RUN apk --no-cache add sqlite-libs

# Set working directory in the container image.
WORKDIR /app

# Copy the YTuner files from host into container image.
COPY x86_64-linux/ /app/
 
# Make the TCP/UDP ports to outside the container.
EXPOSE 80/tcp
EXPOSE 53/udp

# Run YTuner.
CMD ["./ytuner"]

3) Building Docker container

Now you are ready to build your Docker container with YTuner binaries :

ladm@localubuntu20:~/YTuner-docker$ sudo docker build -t ytuner:1.2.2 .
+] Building 0.7s (10/10) FINISHED                                                                                                   docker:default
 => [internal] load build definition from Dockerfile                                                                                           0.0s
 => => transferring dockerfile: 674B                                                                                                           0.0s
 => [internal] load metadata for docker.io/library/alpine:3.19                                                                                 0.5s
 => [internal] load .dockerignore                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                0.0s
 => [1/5] FROM docker.io/library/alpine:3.19@sha256:51b67269f354137895d43f3b3d810bfacd3945438e94dc5ac55fdac340352f48                           0.0s
 => [internal] load build context                                                                                                              0.0s
 => => transferring context: 118B                                                                                                              0.0s
 => CACHED [2/5] RUN apk --no-cache add libc6-compat                                                                                           0.0s
 => CACHED [3/5] RUN apk --no-cache add sqlite-libs                                                                                            0.0s
 => CACHED [4/5] WORKDIR /app                                                                                                                  0.0s
 => CACHED [5/5] COPY x86_64-linux/ /app/                                                                                                      0.0s
 => exporting to image                                                                                                                         0.0s
 => => exporting layers                                                                                                                        0.0s
 => => writing image sha256:0f5a6853d85c813d2351ff27199b2576b619d63863eb4020fa4e08feaf22f7e6                                                   0.0s
 => => naming to docker.io/library/ytuner:1.2.2                                                                                                0.0s

Tip: 1.2.2 is a version related tag. You can use other values.

Congratulations, your YTuner Docker container has been built. You can see it :

ladm@localubuntu20:~/YTuner-docker$ sudo docker images
REPOSITORY    TAG       IMAGE ID       CREATED          SIZE
ytuner        1.2.2     0f5a6853d85c   26 seconds ago   11.4MB

4) Running YTuner in Docker container

Now, you're ready to go:

ladm@localubuntu20:~/YTuner-docker$ sudo docker run --rm --network host -v ~/YTuner:/app/host-shared ytuner:1.2.2
YTuner v1.2.2 Copyright (c) 2024 Greg P. (https://github.com/coffeegreg)
24-1-24 22:20:47 : Inf : Starting services...
24-1-24 22:20:47 : Inf : Successfully loaded 10 my stations.
24-1-24 22:20:47 : Dbg : Database library : 3.44.2.
24-1-24 22:20:47 : Inf : Checking local database.
24-1-24 22:20:47 : Inf : Preparing local database This may take a while...
24-1-24 22:20:47 : Dbg : Creating tables.
24-1-24 22:20:47 : Dbg : Filling out countries table.
24-1-24 22:20:47 : Dbg : Radio-browser.info: GET countries.
24-1-24 22:20:48 : Dbg : Filling out languages table.
24-1-24 22:20:48 : Dbg : Radio-browser.info: GET languages.
24-1-24 22:20:48 : Dbg : Filling out codecs table.
24-1-24 22:20:48 : Dbg : Radio-browser.info: GET codecs.
24-1-24 22:20:48 : Dbg : Filling out tags table.
24-1-24 22:20:48 : Dbg : Radio-browser.info: GET tags.
24-1-24 22:20:49 : Dbg : Creating indexes.
24-1-24 22:20:49 : Dbg : Filling out stations table.
24-1-24 22:20:49 : Dbg : Radio-browser.info: GET stations.
24-1-24 22:21:54 : Dbg : Cleaning tables.
24-1-24 22:22:19 : Dbg : Rebuilding indexes.
24-1-24 22:22:20 : Inf : Local database is ready.
24-1-24 22:22:20 : Inf : DNS Service: listening on: 192.168.1.140:53.
24-1-24 22:22:20 : Inf : Web Service: listening on: 192.168.1.140:80.

If you stop running YTuner container and start it again YTuner will use database or cache files already stored on host shared volume.

ladm@localubuntu20:~/YTuner-docker$ sudo docker run --rm --network host -v ~/YTuner:/app/host-shared ytuner:1.2.2
YTuner v1.2.2 Copyright (c) 2024 Greg P. (https://github.com/coffeegreg)
24-1-24 22:17:38 : Inf : Starting services...
24-1-24 22:17:38 : Inf : Successfully loaded 10 my stations.
24-1-24 22:17:38 : Dbg : Database library : 3.44.2.
24-1-24 22:17:38 : Inf : Checking local database.
24-1-24 22:17:38 : Inf : Local database is ready.
24-1-24 22:17:38 : Inf : DNS Service: listening on: 192.168.1.140:53.
24-1-24 22:17:38 : Inf : Web Service: listening on: 192.168.1.140:80.

That's it. Easy, right?

Summary

This is, of course, a simplified description and you can change the container configuration according to your needs. Use the docker documentation to learn more (https://docs.docker.com).

If you found any errors or inaccuracies in this description, please let me know.