kessibi / libretime-docker

ATTENTION: Libretime now offers a way of running it in docker containers. This project wont see anymore development. One way to get libretime to work within a Docker container
27 stars 12 forks source link

Docker Compose #2

Closed MNTLe-DMGD closed 4 years ago

MNTLe-DMGD commented 4 years ago

Here is the Docker Compose I use:

version: "3.6"
services:
   libretime:
     image: odclive/libretime-docker
     container_name: libretime
     environment:
       - PUID=1000
       - PGID=1000
       - TZ=${TZ}
     volumes:
       - ${USERDIR}/docker/libretime:/srv/airtime/stor
     ports:
       - 80:80
       - 8000:8000
     restart: always

This may be worth adding to a wiki or something.

Cheers again :)

kessibi commented 4 years ago

The wiki and sample docker-compose file are both great ideas. I'll try working on them this week. Thanks again!

MNTLe-DMGD commented 4 years ago

Just a side note, the env variable - ${USERDIR}/docker/libretime:/srv/airtime/stor doesn't work, it's just there to show what would be possible.

If you add it to the docker, it will make it really simple to add an external audio library for things like music, jingles, stabs etc.

There's another path too, which we should probably add for the config files. That way we can edit them and add things like rotations and autodj etc.

I cant remember the path off hand, but I'll have a look around inside the docker, then get back to you with the correct path :)

MNTLe-DMGD commented 4 years ago

Updated Docker Compose with correct paths:

  libretime:
    image: odclive/libretime-docker
    container_name: libretime
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=${TZ}
    volumes:
      - ${USERDIR}/docker/libretime/airtime:/etc/airtime
      - ${USERDIR}/docker/libretime/stor:/srv/airtime/stor
      - ${USERDIR}/docker/libretime/watch:/srv/airtime/watch
    ports:
      - 80:80
      - 8000:8000
    restart: always
    networks:
      - traefik_proxy
    labels:
      - "autoheal=true"
      - "com.centurylinklabs.watchtower.enable=false"

Is there any way to correct the ownership/permissions of the paths after the docker first starts?

I had to manually correct the ownership/permissions (777 and www-data, could probably use 755 if needed) after the initial startup, otherwise installation failed with "cannot copy airtime.conf". I think this relates to /etc/airtime

Also, may want to look some method of creating a persistent DB, so that after an upgrade, it doesn't force a reinstall. :)

"com.centurylinklabs.watchtower.enable=false" ^^ This line is to disable Watchtower from automatically upgrading the image.

MNTLe-DMGD commented 4 years ago

Woops, accidentally closed. Sorry.

kessibi commented 4 years ago

Hey, about everything:

Is there any way to correct the ownership/permissions of the paths after the docker first starts?

This has just been implemented, now the Dockerfile CMD includes changing ownership of some directories for an easier installation.

I had to manually correct the ownership/permissions

I pushed v0.1 to Docker Hub, on which you won't have to do this trick again. I'll try to update the README as soon as possible

may want to look some method of creating a persistent DB, so that after an upgrade, it doesn't force a reinstall. :)

Indeed, this should be one of the priority, but I have some others such as the docker-compose file. I have started working on a slightly modified version of yours and everything works great but when composing down and up again, libretime seems to be missing some files because it renders the error page. (I used a .env file for the variables).

docker-compose.yml


services:
  libretime:
    image: odclive/libretime-docker:v0.1
    container_name: libretime
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=${TZ}
    volumes:
      - ${USERDIR}/docker/libretime/airtime:/etc/airtime
      - ${USERDIR}/docker/libretime/stor:/srv/airtime/stor
      - ${USERDIR}/docker/libretime/watch:/srv/airtime/watch
    ports:
      - 80:80
      - 8000:8000
    restart: always
    labels:
      - "autoheal=true"
      - "com.centurylinklabs.watchtower.enable=false"
kessibi commented 4 years ago

I added postgres persistency (and thus libretime persistency) in commit https://github.com/kessibi/libretime-docker/commit/fa751812a80550c3ef0016c493763b284add86e5.

The image odclive/libretime-docker has been updated on both current tags latest and v0.1. I will rework the README and wiki pages so they are easier to use. A docker-compose has been added but I did not feel the need to put:

    labels:
      - "autoheal=true"
      - "com.centurylinklabs.watchtower.enable=false"

I did not really understand what these were for, maybe you can help me on this? Thanks, once again, for your inputs on the project :airplane:

MNTLe-DMGD commented 4 years ago

I pushed v0.1 to Docker Hub, on which you won't have to do this trick again. I'll try to update the README as soon as possible

Great work, just going to pull the latest version to test. 😃

I did not really understand what these were for, maybe you can help me on this?

Ok, so autoheal and watchtower are two other docker images I run. Autoheal monitors and restarts unhealthy docker containers, and I use Watchtower to update the images automatically, and to send me notifications via Gotify.

The watchtower label is set to false to stop watchtower from updating it. This is because persistence was still a problem.

They are definitely not needed, but could be added later to a wiki. It would be a good way to keep everyone up to date. 😁

I'll test the new version and let you know how I go 👍

MNTLe-DMGD commented 4 years ago

Great work on the new version! I got persistence working!

I found a few issues though. I'll explain what I did:

I hope these steps help you narrow down everything you need.

Since I've done the above, I can now restart, delete and recreate the docker with a persistent storage and database 😁

kessibi commented 4 years ago

Added a line to my docker-compose volumes: ${USERDIR}/docker/libretime/postgres:/var/lib/postgresql/10/main

The problem with this is that volume linking is done after the container starts. If the directory does not exit, it creates it before linking it. The problem of all of this is that host data is copied to container and not the other around, thus emptying /var/lib/postgresql/.... The trick I found was to use a proper Docker volume instead of mounting like you did. (Seeable here: https://github.com/kessibi/libretime-docker/wiki/Sample-installation)

If people prefer to use dir mounting as you did, I'll probably add a commend about it in the wiki.

EDIT: Using a nameless volume also means a lot less pain for installation, the only shell command they'll ever have to run is /libre_start.sh to start the services and I'd like the tool to be really easy to use/setup.

MNTLe-DMGD commented 4 years ago

Using a nameless volume also means a lot less pain for installation, the only shell command they'll ever have to run is /libre_start.sh to start the services and I'd like the tool to be really easy to use/setup.

That's interesting! Ok. I'll give it another go. I'll post results.

EDIT: Holy crap! That got it alright! Excellent work buddy!

Persistence works perfectly, using a named volume! I'm impressed. Kudos indeed. 😄

kessibi commented 4 years ago

Hehe, I'll take your enthuisiasm as a positive feedback to the docker-compose file. I think the work on this issue is done. About autoheal, watchtower and gotify, I would prefer to give the simplest, down to earth image and examples. This way people can easily spice it up their way. It also makes it easier to understand what's necessary and what's not.

Thanks for your continuous feedback!

MNTLe-DMGD commented 4 years ago

About autoheal, watchtower and gotify, I would prefer to give the simplest, down to earth image and examples. This way people can easily spice it up their way

Absolutely. The only reason I included it, was 1. I was being lazy, and 2. I thought perhaps you might find it useful.

You're doing great mate. Resolving issues this quickly, should result in an excellent result.

I've been looking for an easy way to use Libretime/Airtime with docker for ages, and so far, your solution has been an amazing step forward from the current offerings out there.

Let me know if there's anything else I can do to help. 😄

kessibi commented 4 years ago

I've pinged the libretime official repo using an issue: https://github.com/LibreTime/libretime/issues/949 to talk about this installation method. Maybe we'll get some further updates from them.