diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 1bb2ff0..3905f49 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,2 @@ -patreon: DevilXD -custom: "https://www.buymeacoffee.com/DevilXD" -github: DevilXD +custom: "https://buymeacoffee.com/rangermix" +github: rangermix diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d57992..5b2951a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,9 +58,9 @@ jobs: - name: Append git revision to project version run: | - (Get-Content version.py) ` + (Get-Content src/version.py) ` -Replace '^__version__\s*=\s*"[^"]+', "`$0.${{steps.vars.outputs.sha_short}}" |` - Out-File version.py + Out-File src/version.py # Ensure Python version - name: Set up Python @@ -131,7 +131,7 @@ jobs: - name: Append git revision to project version run: | - sed -ri "s/^__version__\s*=\s*\"[^\"]+/\0.${{steps.vars.outputs.sha_short}}/" version.py + sed -ri "s/^__version__\s*=\s*\"[^\"]+/\0.${{steps.vars.outputs.sha_short}}/" src/version.py # Ensure Python version - name: Set up Python @@ -209,12 +209,12 @@ jobs: - name: Set up variables id: vars run: | - echo "app_version=$(python3 -c 'from version import __version__ as v; print(v)')" >> "${GITHUB_OUTPUT}" + echo "app_version=$(python3 -c 'import sys; sys.path.insert(0, "src"); from version import __version__ as v; print(v)')" >> "${GITHUB_OUTPUT}" echo "sha_short=$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}" - name: Append git revision to project version run: | - sed -ri "s/^__version__\s*=\s*\"[^\"]+/\0.${{steps.vars.outputs.sha_short}}/" version.py + sed -ri "s/^__version__\s*=\s*\"[^\"]+/\0.${{steps.vars.outputs.sha_short}}/" src/version.py - name: Install system dependencies run: | @@ -249,6 +249,62 @@ jobs: name: Twitch.Drops.Miner.Linux.AppImage-${{matrix.arch}} path: Twitch.Drops.Miner.Linux.AppImage-${{matrix.arch}}.zip + docker: + name: Docker Build + runs-on: ubuntu-latest + needs: + - validate + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up variables + id: vars + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}" + echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{github.repository}} + tags: | + type=raw,value=dev + type=raw,value=dev-${{steps.vars.outputs.sha_short}} + type=raw,value=latest,enable=${{github.ref == 'refs/heads/master'}} + type=sha,prefix= + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{github.event_name != 'pull_request'}} + tags: ${{steps.meta.outputs.tags}} + labels: ${{steps.meta.outputs.labels}} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILD_DATE=${{steps.vars.outputs.date}} + VCS_REF=${{github.sha}} + VERSION=dev-${{steps.vars.outputs.sha_short}} + update_releases_page: name: Upload builds to Releases if: github.event_name != 'pull_request' diff --git a/Dockerfile b/Dockerfile index e3d9b04..6ea35fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,22 @@ FROM python:3.11-slim +# Build arguments for metadata +ARG BUILD_DATE +ARG VCS_REF +ARG VERSION + +# Labels following OCI Image Format Specification +LABEL org.opencontainers.image.created="${BUILD_DATE}" \ + org.opencontainers.image.authors="rangermix" \ + org.opencontainers.image.url="https://github.com/rangermix/TwitchDropsMiner" \ + org.opencontainers.image.documentation="https://github.com/rangermix/TwitchDropsMiner/blob/master/README.md" \ + org.opencontainers.image.source="https://github.com/rangermix/TwitchDropsMiner" \ + org.opencontainers.image.version="${VERSION}" \ + org.opencontainers.image.revision="${VCS_REF}" \ + org.opencontainers.image.vendor="rangermix" \ + org.opencontainers.image.title="Twitch Drops Miner" \ + org.opencontainers.image.description="Automated Twitch drops mining application with web-based interface" + # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ @@ -15,13 +32,14 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Copy requirements file -COPY requirements-web.txt . +COPY requirements.txt . # Install Python dependencies -RUN pip install --no-cache-dir -r requirements-web.txt +RUN pip install --no-cache-dir -r requirements.txt # Copy application code -COPY *.py ./ +COPY main.py ./ +COPY src/ ./src/ COPY lang/ ./lang/ COPY icons/ ./icons/ COPY web/ ./web/ @@ -36,5 +54,5 @@ EXPOSE 8080 HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/api/status')" || exit 1 -# Run with web GUI -CMD ["python", "main.py", "--web", "-v"] +# Run the application (web GUI is now default) +CMD ["python", "main.py", "-v"] diff --git a/README.md b/README.md index 9b7a2ec..4e7aef7 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,23 @@ The application features a modern web-based interface accessible from any browse The application is designed for Docker deployment, making it easy to run on any platform: +**Using pre-built images (Recommended):** + +```bash +# Pull and run from GitHub Container Registry +docker pull ghcr.io/rangermix/twitchdropsminer:latest +docker run -d -p 8080:8080 -v $(pwd)/data:/app/data ghcr.io/rangermix/twitchdropsminer:latest + +# Or use docker-compose with the pre-built image +# Create a docker-compose.yml file with: +# services: +# twitch-drops-miner: +# image: ghcr.io/rangermix/twitchdropsminer:latest +# ... +``` + +**Building locally:** + ```bash # Build and run with docker-compose docker-compose up -d @@ -100,6 +117,8 @@ docker run -d -p 8080:8080 -v $(pwd)/data:/app/data twitch-drops-miner - Browser notifications supported (requires permission) - Health checks and automatic restart included in docker-compose - Configure timezone with `TZ` environment variable +- Pre-built images are automatically built from the master branch via GitHub Actions +- Available tags: `latest` (stable), `dev` (latest development build) ### Running from Source: diff --git a/docker-compose.yml b/docker-compose.yml index 1cc4440..feb7f02 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: twitch-drops-miner: build: .