From 9ccf2f60ea6cbb710c47f75ad9df142df2cd1595 Mon Sep 17 00:00:00 2001 From: Thomas Couchoud Date: Thu, 18 Nov 2021 13:04:22 +0100 Subject: [PATCH] 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 0000000..1230149 --- /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 0000000..7bace73 --- /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 0000000..350ceb0 --- /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 7bc3182..4c012ff 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.