Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Docker #234

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/github-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Github Registry

on:
push:
branches:
- '**'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
name: Push Docker Image to Github Registry
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: ./docker/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ Alternatively, the tool can be installed with ``git``:
$ cd chat-downloader
$ python setup.py install

The tool can be used with ``docker``:

.. code:: console

$ docker run -v /path/to/download/:/home/download/ -e channelURL='https://www.twitch.tv/twitch' -e channelName='twitch' -e fileFormat='json' -e uid='1000' -e gid='1000' ghcr.io/xenova/chat-downloader:master


#####
Usage
Expand Down Expand Up @@ -118,6 +124,19 @@ Python
For advanced python use-cases and examples, consult the `Python Documentation <https://chat-downloader.readthedocs.io/en/latest/source/index.html#python-documentation>`_.


Docker
------

- **/home/download** - the place where the file will be saved. Mount it to a desired place with -v option.
- **channelURL** - the url of the stream you want to record.
- **channelName** - the name for the stream.
- **fileFormat** - file extension to be used.
- **uid** - UserID, map to your desired User ID (fallback to 9001)
- **gid** - GroupID, map to your desired Group ID (fallback to 9001)

The File will be saved as channelName-YearMonthDate-HourMinuteSecond.ext


##########
Chat Items
##########
Expand Down
24 changes: 24 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM python:3.12
LABEL maintainer="lauwarm@mailbox.org"

WORKDIR /app

RUN apt-get update && apt-get install gosu -y

COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt

RUN echo 'export PATH="${HOME}/.local/bin:${PATH}"'

COPY . /app

RUN mkdir /home/download
RUN mkdir /home/script

COPY ./entrypoint.sh /home/script/

RUN ["chmod", "+x", "/home/script/entrypoint.sh"]

ENTRYPOINT [ "/home/script/entrypoint.sh" ]

CMD python download_chat.py ${channelURL} ${channelName} ${fileFormat}
11 changes: 11 additions & 0 deletions docker/download_chat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import subprocess, sys
from datetime import datetime

channel_url = sys.argv[1]
channel_name = sys.argv[2]
file_format = sys.argv[3]

now = datetime.now()
d1 = now.strftime("%Y%m%d-%H%M%S")

subprocess.run(['chat_downloader', channel_url, '--output', "/home/download/"+channel_name+"-"+d1+'.'+file_format])
14 changes: 14 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Add local user and group
# Either use the uid and gid if passed in at runtime or
# fallback to 9001

USER_ID=${uid:-9001}
GROUP_ID=${gid:-9001}

echo "UID : $USER_ID \nGID : $GROUP_ID"

chown -R $USER_ID:$GROUP_ID /home/script

exec gosu $USER_ID "$@"
1 change: 1 addition & 0 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chat-downloader==0.2.8
25 changes: 25 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ Alternatively, the tool can be installed with ``git``:
$ cd chat-downloader
$ python setup.py install

The tool can be used with ``docker``:

.. code:: console

$ docker run -v /path/to/download/:/home/download/ -e channelURL='https://www.twitch.tv/twitch' -e channelName='twitch' -e fileFormat='json' -e uid='1000' -e gid='1000' ghcr.io/xenova/chat-downloader:master

#####
Usage
Expand Down Expand Up @@ -99,6 +104,26 @@ Python
For advanced python use-cases and examples, consult the :ref:`Python Documentation`.


Docker
------

.. code:: console

/home/download - the place where the file will be saved. Mount it to a desired place with -v option.

channelURL - the url of the stream you want to record.

channelName - the name for the stream.

fileFormat - file extension to be used.

uid - UserID, map to your desired User ID (fallback to 9001)

gid - GroupID, map to your desired Group ID (fallback to 9001)


The File will be saved as streamName-YearMonthDate-HourMinuteSecond.ext

##########
Chat Items
##########
Expand Down