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

Dockerfile with CI #343

Merged
merged 5 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
35 changes: 35 additions & 0 deletions .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy on Docker hub

on:
push:
branches: [master]
workflow_dispatch:
Tkd-Alex marked this conversation as resolved.
Show resolved Hide resolved

jobs:
deploy-docker:
name: Deploy Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/[email protected]
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/[email protected]
with:
context: .
push: true
tags: |
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 }}
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM python:3-slim-buster

ARG BUILDX_QEMU_ENV

WORKDIR /usr/src/app

COPY ./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 \
Tkd-Alex marked this conversation as resolved.
Show resolved Hide resolved
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/*

ADD ./TwitchChannelPointsMiner ./TwitchChannelPointsMiner
ENTRYPOINT [ "python", "run.py" ]
80 changes: 63 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Currently, we have a lot of PRs requests opened, but the time to test and improv
- [Less logs](#less-logs)
- [Final report](#final-report)
4. 🧐 [How to use](#how-to-use)
- [Cloning](#by-cloning-the-repository)
- [pip](#pip)
- [Docker](#docker)
- [Limits](#limits)
5. 🔧 [Settings](#settings)
- [LoggerSettings](#loggersettings)
Expand Down Expand Up @@ -171,23 +174,7 @@ No browser needed. [#41](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner
```

## How to use:
### Download via pip
Via pip you can download the stable version of the project.

`pip install Twitch-Channel-Points-Miner-v2`

### Download via Github
Via GitHub you can download the latest version of the project.
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
pip install virtualenv
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
```

Then create your `run.py` file start from [example.py](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/blob/master/example.py).
First of all please create a run.py file. You can just copy [example.py](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/blob/master/example.py) and modify it according to your needs.
```python
# -*- coding: utf-8 -*-

Expand Down Expand Up @@ -284,8 +271,67 @@ from TwitchChannelPointsMiner import TwitchChannelPointsMiner
twitch_miner = TwitchChannelPointsMiner("your-twitch-username")
twitch_miner.mine(followers=True, blacklist=["user1", "user2"]) # Blacklist example
```

### 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
pip install virtualenv
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
```

Start mining! `python run.py` 🥳

### pip
Install the package via pip, you will find a stable version - maybe a different version from the master branch.
- `pip install Twitch-Channel-Points-Miner-v2`
- Exceute the run.py file `python run.py` 🥳

### Docker

The following file is mounted :

- run.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: tkdalex/twitch-channel-points-miner-v2
tty: true
environment:
- TERM=xterm-256color
volumes:
- ./analytics:/usr/src/app/analytics
- ./cookies:/usr/src/app/cookies
- ./logs:/usr/src/app/logs
- ./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 \
Tkd-Alex marked this conversation as resolved.
Show resolved Hide resolved
-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.

Expand Down