milaq / YCast

Self hosted vTuner internet radio service emulation
Other
243 stars 93 forks source link

Add docker image #13

Open milaq opened 5 years ago

milaq commented 5 years ago

Some may find the deployment cumbersome. Create a nice docker image for those.

mnasec commented 4 years ago

Hi Milaq, attached you will find a basic dockerfile for building a ycast container. The container will be about 76MB and is based von alpine linux. It builds the container based on your ycast 1.0.0 you released today. Just put both files in a directory an build your own image. It works for me on the synology NAS also.

#docker build --compress -f ycast-dockerfile-v6 -t yourrepro/ycast-docker:v6 .

ycast-docker.zip

milaq commented 4 years ago

Thanks :+1: I'll have a look at it.

mnasec commented 4 years ago

Hi Milaq, i optimized the image and deleted all unnecessary stuff out of the image, include the *.pyc files, they will be recreated during runtime. Now the image is about 40MB as a tar file using this dockerfile: ycast-docker-v9.zip Attached you will find the file as tar.gz: ycast-docker-v9.tar.gz

CU

MaartenSanders commented 4 years ago

Hi Milaq, mnasec,

Excellent work. I posted a docker image in docker hub (https://hub.docker.com/r/netraams/ycast-docker. Had to make one small change to the permissions of bootstrap.sh

Yocee84 commented 4 years ago

Hi! Please write step by step he install.

I use docker in Synology. I found the image. I installed with no lucky. We need special settings? ( especially the volume and the install path? what is it?) or we need a simple install? But when i ssh to syno as root, cant fint anything in ycast in opt.

MaartenSanders commented 4 years ago

Hi Yocee84, I don't have a Synology but just a regular docker install.

The container folder /opt/ycast/stations is linked to host folder /mnt/data/docker_appdata/ycast/opt/ycast in the host folder I have one file: stations.yml with contents:

Nederlandse radio: NPO Radio 1: http://icecast.omroep.nl/radio1-bb-mp3 NPO Radio 2: http://icecast.omroep.nl/radio2-bb-mp3 NPO Radio 3: http://icecast.omroep.nl/3fm-bb-mp3 NPO Radio 4: http://icecast.omroep.nl/radio4-bb-mp3 BNR: http://icecast-bnr.cdp.triple-it.nl/bnr_mp3_128_03 Sky Radio: http://19993.live.streamtheworld.com/SKYRADIO.mp3 Qmusic: http://icecast-qmusicnl-cdp.triple-it.nl/Qmusic_nl_live_96.mp3 Radio 10: http://stream.radio10.nl/radio10

Electronic: Deep House Lounge: http://198.15.94.34:8006 Ibiza Sonica: http://s1.sonicabroadcast.com:7005/stream Bassdrive: http://50.7.98.106:8200 SomaFM Fluid: http://ice1.somafm.com/fluid-128-mp3

Chillout: Joint Radio: http://radio.jointil.net:9998 SomaFM DEF CON Radio: http://ice1.somafm.com/defcon-256-mp3 SomaFM Drone Zone: http://ice1.somafm.com/dronezone-256-mp3 SomaFM Mission Control: http://ice1.somafm.com/missioncontrol-128-mp3 The Jazz Groove: http://west-mp3-128.streamthejazzgroove.com Radionomy Downbeat: http://streaming.radionomy.com/TempoOfTheDownbeat1

Casual: 76Radio: http://192.240.102.133:9566/stream SomaFM Beat Blender: http://ice1.somafm.com/beatblender-128-mp3 Jazz Radio Electro Swing: http://jazz-wr04.ice.infomaniak.ch/jazz-wr04-128.mp3 SomaFM Groove Salad: http://ice1.somafm.com/groovesalad-256-mp3 SomaFM Lush: http://ice1.somafm.com/lush-128-mp3 Allzic Radio R&B: http://allzic10.ice.infomaniak.ch/allzic10.mp3 The UK 1940s Radio Station: http://91.121.134.23:8100/1

Yocee84 commented 4 years ago

Thanks!

tomtastic commented 4 years ago

Thanks @MaartenSanders , if it helps anyone, here's my docker-compose.yml for use with Traefik 2.x, which I then point to with dnsmasq :

---
version: '2.4'
services:

  ycast:
    image: netraams/ycast-docker:v10
    container_name: ycast
    networks:
      - proxy
    expose:
      - 80
    volumes:
      - /data/docker/ycast/stations.yml:/opt/ycast/stations.yml
    mem_limit: 128m
    security_opt:
      - no-new-privileges:true
    restart: unless-stopped
    labels:
      traefik.enable: true
      traefik.http.routers.ycast.entryPoints: "http"
      traefik.http.routers.ycast.service: "ycast"
      traefik.http.services.ycast.loadbalancer.server.port: 80
      traefik.http.routers.ycast.rule: "Host(`denon.vtuner.com`, `denon2.vtuner.com`, `logo.vtuner.net`)"

networks:
  proxy:
    external: true
    name: proxy
...

/etc/dnsmasq.d/vtuner_to_docker_ycast.conf

address=/denon.vtuner.com/192.168.0.18
address=/denon2.vtuner.com/192.168.0.18
address=/logo.vtuner.net/192.168.0.18
mpvd commented 4 years ago

Hi, thank you for this great projekt! Based on your work and the dockerfile of netraams I created a docker for Raspberry Pi: Github and Docker Hub

Run it with the following command (or create your own with the description in Github or Docker Hub): docker run -d --name vtuner-ycast -v /home/vtuner/:/srv/ycast/ycast/stations/ -p 80:80 --restart unless-stopped mpvd/vtuner-emulator-ycast:latest

Have fun! :-)

Michi491 commented 4 years ago

Hi Milaq, mnasec,

Excellent work. I posted a docker image in docker hub (https://hub.docker.com/r/netraams/ycast-docker. Had to make one small change to the permissions of bootstrap.sh

Hi @MaartenSanders, thank you very much for your container.

A few questions cause I'm quite a noob. For info, i've deployed your container on my syno:

You write "Set YC_STATIONS=/opt/ycast/stations/stations.yml and bind a volume to /opt/ycast/stations/ where I drop my stations.yml file." but in the meantime you define the variables ENV YC_STATIONS /opt/ycast/stations.yml in the build files.

In the first case, if I bind my folder containing stations.yml to /opt/ycast/, the container will not start and I will have

/usr/bin/python3: No module named ycast in my log files

In the second case, If I bind a folder to /opt/ycast/stations, it will work properly.

Is this a bug ? or maybe you can explain to me why using /opt/ycast/ for stations.yml doesn't work ?

Thanks again for your work. It really helps.

MaartenSanders commented 4 years ago

Hi Milaq, mnasec, Excellent work. I posted a docker image in docker hub (https://hub.docker.com/r/netraams/ycast-docker. Had to make one small change to the permissions of bootstrap.sh

Hi @MaartenSanders, thank you very much for your container.

A few questions cause I'm quite a noob. For info, i've deployed your container on my syno:

You write "Set YC_STATIONS=/opt/ycast/stations/stations.yml and bind a volume to /opt/ycast/stations/ where I drop my stations.yml file." but in the meantime you define the variables ENV YC_STATIONS /opt/ycast/stations.yml in the build files.

In the first case, if I bind my folder containing stations.yml to /opt/ycast/, the container will not start and I will have

/usr/bin/python3: No module named ycast in my log files

In the second case, If I bind a folder to /opt/ycast/stations, it will work properly.

Is this a bug ? or maybe you can explain to me why using /opt/ycast/ for stations.yml doesn't work ?

Thanks again for your work. It really helps.

It is not a bug. Just how you define your local volume mappings.

Michi491 commented 4 years ago

Thanks, so If I understand correctly, I must define any folder betwen /ycast and /stations.yml for ENV YC_STATIONS and must map my local folder to this folder ?

MaartenSanders commented 4 years ago

Michi491,

I have difficulties to understand the issue your are facing, I works now isn't it? As I write my setup is to Set YC_STATIONS=/opt/ycast/stations/stations.yml and bind a volume to /opt/ycast/stations/ where I drop my stations.yml file. So yes, it is different in the build file but that is how it came in the v9 version of mnasec (FWIW I use portainer so set the ENV from there). The only change I made to the docker file was on the permissions of bootstrap.sh.

Michi491 commented 4 years ago

Yes, it works, no prob. I was just curious and initially thought it could also works without adding "/stations/". Thanks again

mpvd commented 3 years ago

Hi all, thank you for the new Version (1.1.0) of YCast. It works great! I integrated it also in my Docker for RaspberryPi and made a lot of adjustments inside the docker: https://hub.docker.com/r/mpvd/vtuner-emulator-ycast For any questions let me know.

toastemeister commented 3 years ago

For anyone trying to get a traefik rule for use with a Yamaha I eventually discovered that my Yamaha v677 was not sending a host header so my attempts to use that in the traefik rules were failing.

I was able to use an User-Agent rule though. For my Yamaha the User-Agent was: User-Agent: AV_Receiver/3.1 (RX-V677)

traefik 1.7 rule I used was: traefik.frontend.rule: "HeadersRegexp:User-Agent,AV_Receiver*"

This should match other Yamaha models / firmware updates but if not you might need to intercept the request in Wireshark to find out what the User-Agent your amp is sending.

Likely any proxy solution that uses the host header to direct requests to the correct backend, such as Nginx, will have a similar issue with these Yamahas.

MaartenSanders commented 3 years ago

Hi Milaq, mnasec, Excellent work. I posted a docker image in docker hub (https://hub.docker.com/r/netraams/ycast-docker. Had to make one small change to the permissions of bootstrap.sh

Hi @MaartenSanders, thank you very much for your container. A few questions cause I'm quite a noob. For info, i've deployed your container on my syno: You write "Set YC_STATIONS=/opt/ycast/stations/stations.yml and bind a volume to /opt/ycast/stations/ where I drop my stations.yml file." but in the meantime you define the variables ENV YC_STATIONS /opt/ycast/stations.yml in the build files. In the first case, if I bind my folder containing stations.yml to /opt/ycast/, the container will not start and I will have /usr/bin/python3: No module named ycast in my log files In the second case, If I bind a folder to /opt/ycast/stations, it will work properly. Is this a bug ? or maybe you can explain to me why using /opt/ycast/ for stations.yml doesn't work ? Thanks again for your work. It really helps.

It is not a bug. Just how you define your local volume mappings.

Hi Milaq, mnasec, Excellent work. I posted a docker image in docker hub (https://hub.docker.com/r/netraams/ycast-docker. Had to make one small change to the permissions of bootstrap.sh

Hi @MaartenSanders, thank you very much for your container. A few questions cause I'm quite a noob. For info, i've deployed your container on my syno: You write "Set YC_STATIONS=/opt/ycast/stations/stations.yml and bind a volume to /opt/ycast/stations/ where I drop my stations.yml file." but in the meantime you define the variables ENV YC_STATIONS /opt/ycast/stations.yml in the build files. In the first case, if I bind my folder containing stations.yml to /opt/ycast/, the container will not start and I will have /usr/bin/python3: No module named ycast in my log files In the second case, If I bind a folder to /opt/ycast/stations, it will work properly. Is this a bug ? or maybe you can explain to me why using /opt/ycast/ for stations.yml doesn't work ? Thanks again for your work. It really helps.

It is not a bug. Just how you define your local volume mappings.

For all interested, docker image updated to 1.1.0: https://hub.docker.com/r/netraams/ycast-docker

2003flo commented 3 years ago

I set up netraams/ycast-docker:latest on portainer and got a problem. I hope you can help me.

Here are my portainer settings:

Ports:
80:80 TCP and UDP

Volumes:
Hostvolume | Containervolume
/opt/ycast/stations/stations.yml | /opt/ycast/stations/stations.yml

Enviroment:
YC_STATIONS | /opt/ycast/stations/stations.yml
PATH | /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
YC_VERSION | 1.1.0
YC_DEBUG | OFF
YC_PORT | 80

I created a new file called stations.yml in the directory /opt/ycast/stations/stations.yml. This is the content:

Nederlandse radio:
NPO Radio 1: http://icecast.omroep.nl/radio1-bb-mp3
NPO Radio 2: http://icecast.omroep.nl/radio2-bb-mp3

Electronic:
Deep House Lounge: http://198.15.94.34:8006
Ibiza Sonica: http://s1.sonicabroadcast.com:7005/stream

The DNS Server is set up.

When i enter denon.vtuner.com I get redirected to my Ycast Server http://192.168.1.2/ycast/. The page shows:

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

This is my portainer log:

2020-11-14 17:52:38 INFO: YCast (1.1.0) server starting,
 * Serving Flask app "ycast.server" (lazy loading),
 * Environment: production,
   WARNING: This is a development server. Do not use it in a production deployment.,
   Use a production WSGI server instead.,
 * Debug mode: off,
2020-11-14 17:52:40 ERROR: Exception on /ycast/ [GET],
Traceback (most recent call last):,
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app,
    response = self.full_dispatch_request(),
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request,
    rv = self.handle_user_exception(e),
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception,
    reraise(exc_type, exc_value, tb),
  File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise,
    raise value,
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request,
    rv = self.dispatch_request(),
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request,
    return self.view_functions[rule.endpoint](**req.view_args),
  File "/opt/ycast/YCast-1.1.0/ycast/server.py", line 151, in landing,
    len(my_stations.get_category_directories()))),
  File "/opt/ycast/YCast-1.1.0/ycast/my_stations.py", line 64, in get_category_directories,
    categories.append(generic.Directory(category, len(get_stations_by_category(category)))),
  File "/opt/ycast/YCast-1.1.0/ycast/my_stations.py", line 72, in get_stations_by_category,
    for station_name in my_stations_yaml[category]:,
TypeError: 'NoneType' object is not iterable,
tomtastic commented 3 years ago

Is your stations.yml indented as YAML correctly ?

Nederlandse radio:
    NPO Radio 1: http://icecast.omroep.nl/radio1-bb-mp3
    NPO Radio 2: http://icecast.omroep.nl/radio2-bb-mp3

Electronic:
    Deep House Lounge: http://198.15.94.34:8006
    Ibiza Sonica: http://s1.sonicabroadcast.com:7005/stream
MaartenSanders commented 3 years ago

Can you try attached stations.yml file (rename it to stations.yml)? I do recall ycast is a bit picky on the format. Is there a CRLF after you last line? I think it is needed. stations.yml.txt

2003flo commented 3 years ago

I deleted the container and deployed it again. Now the Radiobrowser feature works (yeah!) but the stations.yml doesnt work.

The log says:

2020-11-15 11:51:32 ERROR: Station configuration '/opt/ycast/stations.yml' not found
 * Serving Flask app "ycast.server" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off

Docker Settings:

Port 80:80 UDP and TCP
Enviroment:
PATH | /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
YC_VERSION | 1.1.0
YC_STATIONS | /opt/ycast/stations.yml
YC_DEBUG | OFF
YC_PORT | 80

Volume:
/opt/ycast/stations | /opt/ycast/stations

When I enter the URL in my computer's browser: 1Dirhttp://10.206.145.31/ycast/radiobrowser/?vtuner=truehttp://10.206.145.31/ycast/radiobrowser/?vtuner=true4Display'My Stations' feature not configured.

I used the stations.yml.txt from MaartenSanders. I uploaded it into that directory /opt/ycast/stations/ and renamed it to stations.yml.

ghost commented 3 years ago

Should probably be YC_STATIONS | /opt/ycast/stations/stations.yml

ghost commented 3 years ago

You can find out what's actually the path in your container by running ls in it: docker exec -it ycast /bin/ls /opt/ycast/stations docker exec -it ycast /bin/ls /opt/ycast etc. Make sure to replace 'ycast' with your container name (list container names with docker container ls)

2003flo commented 3 years ago

Thank you cranphin. Editing YC_STATIONS worked for me.

mnasec commented 3 years ago

Added small changes to ycast-dockerfile to support actual alpine Linux. Additional one change in env YC_VERSION to build a image of the actual version with all commits (master.zip). In this case just set 'YC_VERSION master' ycast-docker-v13.zip

Runs on my synology without and modifications, just run 'chmod +x bootstrap.sh' before running the build command:

usage: docker build --compress -f ycast-dockerfile-v13 -t yourrepro/ycast-docker:v13 .

Image size will be about 46MB

navierb commented 1 year ago

For anyone trying to get a traefik rule for use with a Yamaha I eventually discovered that my Yamaha v677 was not sending a host header so my attempts to use that in the traefik rules were failing.

I was able to use an User-Agent rule though. For my Yamaha the User-Agent was: User-Agent: AV_Receiver/3.1 (RX-V677)

traefik 1.7 rule I used was: traefik.frontend.rule: "HeadersRegexp:User-Agent,AV_Receiver*"

This should match other Yamaha models / firmware updates but if not you might need to intercept the request in Wireshark to find out what the User-Agent your amp is sending.

Likely any proxy solution that uses the host header to direct requests to the correct backend, such as Nginx, will have a similar issue with these Yamahas.

That one helped me, thank you!

In my case I am running Caddy as proxy-server and I had to add the following lines

:80 {
    @ycast {
        header User-Agent AV_Receiver*
    }
    handle @ycast {
        reverse_proxy <YCAST-SERVER-IP>:<YCAST-SERVER-PORT>
    }
}

(obviously changing the <YCAST-SERVER-IP> and <YCAST-SERVER-PORT> with the correct values)