From 9ccf2f60ea6cbb710c47f75ad9df142df2cd1595 Mon Sep 17 00:00:00 2001 From: Thomas Couchoud Date: Thu, 18 Nov 2021 13:04:22 +0100 Subject: [PATCH 1/4] Dockerfile with CI --- .github/dependabot.yml | 6 +++++ .github/workflows/deploy-docker.yml | 35 +++++++++++++++++++++++++++ Dockerfile | 29 ++++++++++++++++++++++ README.md | 37 +++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/deploy-docker.yml create mode 100644 Dockerfile diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..12301490 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml new file mode 100644 index 00000000..7bace732 --- /dev/null +++ b/.github/workflows/deploy-docker.yml @@ -0,0 +1,35 @@ +name: Doploy on Docker hub + +on: + push: + branches: [master] + workflow_dispatch: + +jobs: + deploy-docker: + name: Deploy docker hub + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v2.4.0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1.2.0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1.6.0 + - name: Login to DockerHub + uses: docker/login-action@v1.10.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2.7.0 + with: + context: . + push: true + tags: | + mrcraftcod/twitch-miner:latest + platforms: linux/amd64,linux/arm64,linux/arm/v7 + build-args: BUILDX_QEMU_ENV=true + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..350ceb04 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM python:3-slim-buster + +ARG BUILDX_QEMU_ENV + +WORKDIR /usr/src/app + +COPY ./miner/requirements.txt ./ +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --fix-missing --no-install-recommends \ + gcc \ + libffi-dev \ + rustc \ + zlib1g-dev \ + libjpeg-dev \ + libssl-dev \ + && if [ "${BUILDX_QEMU_ENV}" = "true" ] && [ "$(getconf LONG_BIT)" = "32" ]; then \ + pip install -U cryptography==3.3.2; \ + fi \ + && pip install -r requirements.txt \ + && pip cache purge \ + && apt-get remove -y gcc rustc \ + && apt-get autoremove -y \ + && apt-get autoclean -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /usr/share/doc/* + +COPY ./miner . +CMD [ "python", "./main.py" ] \ No newline at end of file diff --git a/README.md b/README.md index 7bc3182b..4c012ff4 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Read more about channels point [here](https://help.twitch.tv/s/article/channel-p - [Less logs](#less-logs) - [Final report](#final-report) 4. 🧐 [How to use](#how-to-use) + - [Cloning](#by-cloning-the-repository) + - [Docker](#docker) - [Limits](#limits) 5. 🔧 [Settings](#settings) - [LoggerSettings](#loggersettings) @@ -159,6 +161,9 @@ No browser needed. [#41](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner ``` ## How to use: + +### By cloning the repository + 1. Clone this repository `git clone https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2` 2. Install all the requirements `pip install -r requirements.txt` . If you have problems with requirements make sure to have at least Python3.6. You could also try to create a virtualenv and then install all the requirements ```sh @@ -262,6 +267,38 @@ twitch_miner.mine(followers=True, blacklist=["user1", "user2"]) # Automatic use ``` 4. Start mining! `python run.py` +### Docker + +The following file is mounted : + +- main.py : this is your starter script with your configuration + +These folders are mounted : + +- analytics : to save the analytics data +- cookies : to provide login information +- logs : to keep logs outside of container + +Example using docker-compose: + +```yml +version: "3.9" + +services: + miner: + image: mrcraftcod/twitch-miner + tty: true + environment: + - TERM=xterm-256color + volumes: + - ./analytics:/usr/src/app/analytics + - ./cookies:/usr/src/app/cookies + - ./logs:/usr/src/app/logs + - ./main.py:/usr/src/app/main.py:ro + ports: + - "5000:5000" +``` + ### Limits > Twitch has a limit - you can't watch more than 2 channels at one time. We take the first two streamers from the list as they have the highest priority. From 1e8775a7f148253b6d32bddfd7d1ae1da2e32253 Mon Sep 17 00:00:00 2001 From: Alessandro Maggio Date: Thu, 18 Nov 2021 13:28:42 +0100 Subject: [PATCH 2/4] Update deploy-docker.yml with tkdalex tag --- .github/workflows/deploy-docker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index 7bace732..a8cdc1fb 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -1,4 +1,4 @@ -name: Doploy on Docker hub +name: Deploy on Docker hub on: push: @@ -7,7 +7,7 @@ on: jobs: deploy-docker: - name: Deploy docker hub + name: Deploy Docker Hub runs-on: ubuntu-latest steps: - name: Checkout source @@ -28,8 +28,8 @@ jobs: context: . push: true tags: | - mrcraftcod/twitch-miner:latest + tkdalex/twitch-channel-points-miner-v2:latest platforms: linux/amd64,linux/arm64,linux/arm/v7 build-args: BUILDX_QEMU_ENV=true - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file + run: echo ${{ steps.docker_build.outputs.digest }} From f81c96085dfff648cc7ff76bd318fd72f90cc1d8 Mon Sep 17 00:00:00 2001 From: Alessandro Maggio Date: Thu, 18 Nov 2021 15:14:33 +0100 Subject: [PATCH 3/4] update README.md with docker run command. Update Dockerfile (ADD ./TwitchChannelPointsMiner) --- .github/workflows/deploy-docker.yml | 2 +- Dockerfile | 7 ++++--- README.md | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index a8cdc1fb..cfed12c2 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -28,7 +28,7 @@ jobs: context: . push: true tags: | - tkdalex/twitch-channel-points-miner-v2:latest + tkdalex/twitch-channel-points-miner-v2:latest platforms: linux/amd64,linux/arm64,linux/arm/v7 build-args: BUILDX_QEMU_ENV=true - name: Image digest diff --git a/Dockerfile b/Dockerfile index 350ceb04..ae2c900a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,8 @@ ARG BUILDX_QEMU_ENV WORKDIR /usr/src/app -COPY ./miner/requirements.txt ./ +COPY ./requirements.txt ./ + RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --fix-missing --no-install-recommends \ gcc \ @@ -25,5 +26,5 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --fix-missing --no-ins && rm -rf /var/lib/apt/lists/* \ && rm -rf /usr/share/doc/* -COPY ./miner . -CMD [ "python", "./main.py" ] \ No newline at end of file +ADD ./TwitchChannelPointsMiner ./TwitchChannelPointsMiner +ENTRYPOINT [ "python", "run.py" ] diff --git a/README.md b/README.md index e19c318b..0e513bf8 100644 --- a/README.md +++ b/README.md @@ -293,7 +293,7 @@ Install the package via pip, you will find a stable version - maybe a different The following file is mounted : -- main.py : this is your starter script with your configuration +- run.py : this is your starter script with your configuration These folders are mounted : @@ -301,14 +301,14 @@ These folders are mounted : - cookies : to provide login information - logs : to keep logs outside of container -Example using docker-compose: +**Example using docker-compose:** ```yml version: "3.9" services: miner: - image: mrcraftcod/twitch-miner + image: tkdalex/twitch-channel-points-miner-v2 tty: true environment: - TERM=xterm-256color @@ -316,11 +316,22 @@ services: - ./analytics:/usr/src/app/analytics - ./cookies:/usr/src/app/cookies - ./logs:/usr/src/app/logs - - ./main.py:/usr/src/app/main.py:ro + - ./run.py:/usr/src/app/run.py:ro ports: - "5000:5000" ``` +Example with docker run: +```sh +docker run \ + -v $(pwd)/analytics:/usr/src/app/analytics \ + -v $(pwd)/cookies:/usr/src/app/cookies \ + -v $(pwd)/logs:/usr/src/app/logs \ + -v $(pwd)/run.py:/usr/src/app/run.py:ro \ + -p 5000:5000 \ + tkdalex/twitch-channel-points-miner-v2 +``` + ### Limits > Twitch has a limit - you can't watch more than two channels at one time. We take the first two streamers from the list as they have the highest priority. From 839ad06e0832519a302ca3f5aee492d6c9ccf3a8 Mon Sep 17 00:00:00 2001 From: Alessandro Maggio Date: Fri, 19 Nov 2021 12:51:47 +0100 Subject: [PATCH 4/4] Upload README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0e513bf8..b12d5e8b 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,10 @@ docker run \ tkdalex/twitch-channel-points-miner-v2 ``` +`$(pwd)` Could not work on Windows (cmd), please us the absolute path instead, like: `-v /path/of/your/cookies:/usr/src/app/cookies`. +If you don't mount the volume for the analytics (or cookies or logs) folder, the folder will be automatically created on the Docker container, and you will lose all the data when it is stopped. +If you don't have a cookie or It's your first time running the script, you will need to login to Twitch and start the container with `-it` args. + ### Limits > Twitch has a limit - you can't watch more than two channels at one time. We take the first two streamers from the list as they have the highest priority.