rocky4546 / tvheadend-locast

service that streams from locast to tvheadend
Other
12 stars 1 forks source link

Docker Settings #6

Open rocky4546 opened 3 years ago

rocky4546 commented 3 years ago

The .alpine and .slim-buster Docker file gives the following error: ERROR: Config file missing, Exiting... Adding the following line to either makes the docker run without error. COPY *.ini /app/ Question is... how is it working for the developers when it seems to be missing the line?

rocky4546 commented 3 years ago

This issue is to mainly determine the end structure to use to support the different environments especially docker.

As for folder structure, an effective docker container would provide the static files to the /apps area while providing the data and cache area that changes to an area mounted externally. Since the configuration definition files are static, they should be moved into the lib folder. I recommend placing them into a resource folder that would contain other resources such as a language area. The other non-python area is the web area that contains the html, javascript, images, and css files that are directly provided to the web port.

The web interface is unique, in that, it also contains dynamic files that are created based on other data. These could be templates or even python CGI type files. It would make sense to place the dynamic files somewhere near the web static files.

The config.ini file should be searched in the ./data area or the top level folder, but since the data area is unknown until after the config file is loaded, the config.ini file path must be passed into the application as an argument if not in a default location.

rocky4546 commented 3 years ago

Here is what I have determine. With the Dockerfile NOT containing the ini file, the following command can be used once the container is built. sudo docker run -p 6077:6077 -v [location of the data area]:/app/data -rm tvh8.0.0-alpha001 This command will run the docker app with the data folder containing the data files from an external mount point. This allows for the data and cache to be updated. Note the config.ini file is located in the data folder. The 6077:6077 also provides an external port so the website can be used externally.

EMBY: automatic detection requires

  1. HDHomerun protocol to be enabled
  2. web-admin port on port 80
  3. IP of the App is on the same primary network as Emby (Docker 172.* network does not work due to Emby broadcasting on 255.255.255.255 local network only)

EMBY: manual detection requires

  1. HDHomerun protocol to be enabled This will work with Docker 172 networks

PLEX: automatic detection requires

  1. HDHomerun protocol enabled
  2. SSDP protocol enabled
  3. web-admin port on port 80
  4. IP of the App is on the same primary network as Plex

PLEX: manual detection requires

  1. HDHomerun protocol enabled This will work with Docker 172 networks

For Docker, first build the container with sudo docker build . -f Dockerfile_tvh_crypt.alpine -t [tag to use] Then to run the container sudo docker run -p 6077:6077 -v [location of data directory on server]:/app/data --rm [tag used earlier]

For the config.ini file associated with Docker... there are no special changes for Docker.

rocky4546 commented 3 years ago

There is a chance if Plex or Emby was installed in a Docker container that the ability to communicate across the 172 network between Emby/Plex and the app is possible. This would make it possible that the automatic detection would be enabled. Complexity of the docker install of Emby/Plex is very high, so it will not be tested.

cookieisland commented 3 years ago

For the alpine and slim buster dockerfiles I use them with docker-compose and I provide with an ini and key file via a volume statement. That way I keep my configuration files in my docker directory and out of the source directory. Here is what my docker-compose file looks like:

 tvheadend-locast:
    build:
      context: /home/cookieisland/source/tvheadend-locast
      dockerfile: Dockerfile_tvh_crypt.slim-buster
    image: tvheadend-locast
    container_name: tvheadend-locast
    environment:
      TZ: "America/Los_Angeles"
    network_mode: "host"
    cpu_shares: 2048
    restart: unless-stopped
    volumes:
      - /home/cookieisland/docker/tvheadend-locast/config/config.ini:/app/config/config.ini
      - /home/cookieisland/docker/tvheadend-locast/config/key.txt:/root/.locast/key.txt
cookieisland commented 3 years ago

wait - I just tried using your new commit and I am now also getting ERROR: Config file missing, Exiting...

cookieisland commented 3 years ago

I figured it out. After your latest commit the config.ini file now must be located in /app/config.ini. Previously it could be located in /app/config/config.ini. I modified my docker-compose volume statement and I am running again. Here is my latest docker-compose.yaml that now works again.

tvheadend-locast:
   build:
     context: /home/cookieisland/source/tvheadend-locast
     dockerfile: Dockerfile_tvh_crypt.slim-buster
   image: tvheadend-locast
   container_name: tvheadend-locast
   environment:
     TZ: "America/Los_Angeles"
   network_mode: "host"
   cpu_shares: 2048
   restart: unless-stopped
   volumes:
     - /home/cookieisland/docker/tvheadend-locast/config/config.ini:/app/config.ini
     - /home/cookieisland/docker/tvheadend-locast/config/key.txt:/root/.locast/key.txt
rocky4546 commented 3 years ago

To simplify things, I moved the config file to /app/data/config.ini. That way, the cache, db and config.ini file can exist outside of the source easily. Most people will have the config.ini at the top level, but for Docker, you should put it into the data area. I use the option -v [location of data directory on server]:/app/data to define where the data folder resides. I had not thought about the encryption key and Docker, but I see you have it also addressed.

rocky4546 commented 3 years ago

question... Almost ready to checkin an update. One change is the ability to easily define config variables such as where things are used or stored. This makes it available to change. Do you think the key location should be available in the path list? My thought is that it is suppose to be in a remote area from the app to keep the private key from being compromised. Showing where it is located is an issue for me. Just wondering, since you placed it with the config file.

cookieisland commented 3 years ago

The main issue I had with docker was that when I regenerated a new docker image the config.ini file was lost/reset so all changes I made with the web based editor were lost. Therefore I saved the config.ini file outside of the docker image so it would not be lost. At that point I ran into the situation where the key file was lost which invalidated the password in my config.ini. I guess i could have simply put my password back into config.ini every time I regenerated the docker image... But I was lazy and figured a way to avoid that. I will think on this to see if there may be an alternate and more secure approach.

On Mon, Apr 12, 2021, 7:20 PM rocky4546 @.***> wrote:

question... Almost ready to checkin an update. One change is the ability to easily define config variables such as where things are used or stored. This makes it available to change. Do you think the key location should be available in the path list? My thought is that it is suppose to be in a remote area from the app to keep the private key from being compromised. Showing where it is located is an issue for me. Just wondering, since you placed it with the config file.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rocky4546/tvheadend-locast/issues/6#issuecomment-818382309, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWA76QCWV3JGZ4GDR4C7JTTIOS7TANCNFSM42NKNWJA .

cookieisland commented 3 years ago

From my perspective you should go ahead and checkin your enhancements. I suspect most people will not encrypt their password. I suggest you put instructions in your doc or wiki saying that ppl will need to re-enter their clear text password in config.ini whenever they regenerate their docker image.

On Mon, Apr 12, 2021, 7:20 PM rocky4546 @.***> wrote:

question... Almost ready to checkin an update. One change is the ability to easily define config variables such as where things are used or stored. This makes it available to change. Do you think the key location should be available in the path list? My thought is that it is suppose to be in a remote area from the app to keep the private key from being compromised. Showing where it is located is an issue for me. Just wondering, since you placed it with the config file.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rocky4546/tvheadend-locast/issues/6#issuecomment-818382309, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWA76QCWV3JGZ4GDR4C7JTTIOS7TANCNFSM42NKNWJA .

rocky4546 commented 3 years ago

Understand on the encryption. Slowly updating the wiki pages, but will update the docker page. For the next update, have a new folder called plugins at the top level. Will update docker files to add it. It has some initial data for base testing. Also, moved around a number of folders inside lib since we are moving further away from locast2plex source. I try to do some PEP cleanup each push. Once that is complete, will checkin updates.

rocky4546 commented 3 years ago

Added a section on Docker in the Wiki installation instructions. Found a solution on the key file and added it to the Wiki. With my limited Docker knowledge, locast2plex has a docker-compose.yml file that probably needs to be updated. It uses relative paths, but using -v on the command line can only use absolute paths. Never used docker-compose, so will need to learn about that, but using relative paths may make it a more consistent solution. The key is located in the home folder, so if we can also use environment variables like $HOME, the docker-compose.yml would be able to be a stable file.

cookieisland commented 3 years ago

In my opinion the best thing to do with Docker is not require your users to download and build their own image. With all the docker images I use the developer generated the image and then uploaded it to a repository like dockerhub.

Here is an example. I use tvheadend and I do not have to download source code. All I do is add the recommended docker-compose code to my docker-compose.yaml file and modify per the documentation.

https://hub.docker.com/r/linuxserver/tvheadend

rocky4546 commented 3 years ago

I agree completely. Just need the time to set it up. Plans include adding debian installers, pip installer as well. I already completed a Windows installer and that is still working. Maybe after I get this plugin thing working, we can look at adding the different installers.

cookieisland commented 3 years ago

No worries. tvheadend-locast works great for me and I will continue to it and test your new versions as well.