oliverjrose99 / Recordurbate

A Bot to automatically record Chaturbate live streams.
GNU General Public License v3.0
235 stars 77 forks source link

Docker #25

Closed neondrift closed 3 years ago

neondrift commented 4 years ago

A docker container would be really cool. Specifically with env variables for the config folder and the download folder, auto updating (ffmpeg, youtube-dl, recordurbate), etc.

oliverjrose99 commented 4 years ago

I know very little about docker but ill add it to the list, if you/anyone would like to submit a PR that would be great as well.

Suika commented 4 years ago

If you can make it so that recordurbate stays in the foreground (and logs to stdout), I'll whip up a dockerfile in a few minutes.

Having logs printed to stdout when in foreground is practical for the way docker works. But if it's a pain, I can redirect it some other way.

Suika commented 4 years ago

I can make it run as it is right now, and watch the pid. But that would be an ugly solution.

neondrift commented 4 years ago

@Suika I started working on one. It is messy. It currently builds but you have to start and stop the underlying process manually.

Uploaded it here: https://hub.docker.com/r/n30ndr1ft/recordurbate

Here's how far I got:

FROM python:alpine
VOLUME /opt/recordurbate/configs
VOLUME /opt/recordurbate/videos
ADD https://codeload.github.com/oliverjrose99/Recordurbate/zip/master /tmp/master.zip
RUN \
    echo "**** install runtime packages ****" && \
        apk update && \
        apk add --nocache --upgrade \
            ffmpeg \
            tzdata && \
        pip3 install --no-cache --upgrade \
            pip \
            requests \
            youtube-dl && \
    echo "**** install recordurbate ****" && \
        cd /tmp && \
        unzip master.zip && \
        cd Recordurbate-master/recordurbate && \
        # mkdir /opt/recordurbate/ && \
        cp --force *.py /opt/recordurbate/ && \
        chmod +x /opt/recordurbate/Recordurbate.py && \
        cd configs && \
        # mkdir /opt/recordurbate/configs && \
        cp *.* /opt/recordurbate/configs && \
    echo "**** configure logging ****" && \
        ln -sf /dev/stdout /opt/recordurbate/configs/rb.log &&\
    echo "**** cleanup ****" && \
        rm -rf \
            /tmp/* \
            /var/tmp/*
CMD ["python", "/opt/recordurbate/Recordurbate.py", "start"]
neondrift commented 4 years ago

I've debated writing an OpenRC init script to handle the start / stop?

ghost commented 4 years ago

https://github.com/LootScooper/docker-recordurbate works pretty much. Only thing is that it doesnt catch the SIGTERM signal so the the Bot.stop() method is not called when the container is stopped. Which is strange because according to this test it should work https://github.com/marians/python-docker-exit

ghost commented 4 years ago

I managed to fix the SIGTERM issue. The container is now fully working, the stop() function is being called when the container stops.

seducingbits commented 4 years ago

can you provide an image via docker hub?

ghost commented 4 years ago

You can build it yourself!

git clone https://github.com/LootScooper/docker-recordurbate.git
cd docker-recordurbate/recordurbate
docker build . -t recordurbate

Then you run it using:

docker start -d --restart unless-stopped -v your-config-folder:/data -v my-video-folder:/videos recordurbate

Make sure you copy config.json and youtube-dl.config to your config folder.

ghost commented 4 years ago

Make sure to change the uid in the dockerfile to match your system I had to change it to 0 so it could run as root otherwise it won't be able to make the folders

ghost commented 4 years ago

Uid 1000 is the uid of my user. I recommend changing it to the uid of your user and not root. Because running containers as root is not recomended although probably harmless in this case.

ghost commented 4 years ago

Yeah that was more of a frankenstein fix cause I was running into a lot of issues getting this to run

ghost commented 4 years ago

you managed to get it to work now?

ghost commented 4 years ago

Not really

ghost commented 4 years ago

what problems are you running into?

ghost commented 4 years ago
  1. ffmpeg is in /usr/local/bin/ but it won't copy to it keeps saying COPY failed: stat /var/lib/docker/tmp/docker-builder317816139/ffmpeg: no such file or directory

I fix that by putting into the same folder as requirment.txt and changing the location in the dockerfile I have the git hub clone to /home/main/Recorders/docker-recordurbate/

ghost commented 4 years ago

whereis ffmpeg ffmpeg: /usr/bin/ffmpeg /usr/local/bin/ffmpeg /usr/share/ffmpeg /usr/share/man/man1/ffmpeg.1.gz

ghost commented 4 years ago

ow im sorry i just noticed my ide didnt upload the ffmpeg binary when pushing to git. Should be fixed now.

ghost commented 4 years ago

I got it to work somewhat like before the logs says it is recording models. But I can't find any videos in my videos folder not even the .part files logs are working

ghost commented 4 years ago

are you using docker-compose?

ghost commented 4 years ago

No I used your commands from this post

ghost commented 4 years ago

I switch to docker-compose Attaching to recordurbate recordurbate | 2020-02-18 19:45:13,089 - smdl - INFO - Started to record angelika_rouge

ghost commented 4 years ago

No video yet

ghost commented 4 years ago

pip install youtube-dl says 2018 verison is already installed currently trying to update it for python3 to 2020 or 2019

ghost commented 4 years ago

ah oke the videos get saved in /videos in the container. So just mount /videos using

-v your/video/path:/videos
ghost commented 4 years ago

The way i intended to run this container tho is using docker-compose.

pip install docker-compose
git clone https://github.com/LootScooper/docker-recordurbate.git
cd docker-recordurbate

then you edit the docker-compose.yml with an editor of your choice. And change " - /srv/sto1/recordubate:/videos" on line 9. You need to change "/srv/sto1/recordubate" to your video path. Then you run:

docker-compose up

Or if you want to run your container detached (In the background)

docker-compose up -d
ghost commented 4 years ago
  1. The hole pip thing was probably a move of desperation I realize that it didn't matter

  2. My config was wrong as it needed to point to /videos/ I kept using my old youtube-dl config.

  3. The last issue was that I was letting the docker container make the folder. That usually okay with the linuxserver dockers I run. However after player around with docker exec dockername youtube-dl it's clear that the folder has to exist before you run the docker otherwise it doesn't have the right permissions or something

ghost commented 4 years ago

Ah yes, The Linux Server images are a bit more user friendly. The reason why you need that mountpoint to work is because /video doesnt exists in the image. It gets created when you create that mountpoint. Since i intended this to be used with docker-compose it is already implied in the docker-compose.yml