From 0f25db7179a13828d625b074a5ce81d56e7dd150 Mon Sep 17 00:00:00 2001 From: Soxoj Date: Sun, 26 Apr 2026 11:18:12 +0200 Subject: [PATCH] Add Docker web image with multi-stage building --- .github/workflows/build-docker-image.yml | 58 ++++++++++++++++++++---- Dockerfile | 11 ++++- README.md | 18 ++++++-- maigret/resources/db_meta.json | 2 +- sites.md | 2 +- 5 files changed, 75 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 92c1122..03a399e 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -2,7 +2,7 @@ name: Build docker image and push to DockerHub on: push: - branches: [ main ] + branches: [ main, dev ] jobs: docker: @@ -10,24 +10,62 @@ jobs: steps: - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 + name: Extract metadata (CLI) + id: meta_cli + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKER_HUB_USERNAME }}/maigret + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=sha,prefix= + - + name: Extract metadata (Web UI) + id: meta_web + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKER_HUB_USERNAME }}/maigret + tags: | + type=raw,value=web,enable={{is_default_branch}} + type=ref,event=branch,suffix=-web + type=sha,prefix=web- + - + name: Build and push (CLI, default) + id: docker_build_cli + uses: docker/build-push-action@v6 with: push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/maigret:latest + target: cli + tags: ${{ steps.meta_cli.outputs.tags }} + labels: ${{ steps.meta_cli.outputs.labels }} platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + name: Build and push (Web UI) + id: docker_build_web + uses: docker/build-push-action@v6 + with: + push: true + target: web + tags: ${{ steps.meta_web.outputs.tags }} + labels: ${{ steps.meta_web.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max + - + name: Image digests + run: | + echo "cli: ${{ steps.docker_build_cli.outputs.digest }}" + echo "web: ${{ steps.docker_build_web.outputs.digest }}" diff --git a/Dockerfile b/Dockerfile index 81bf6e7..77f0703 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11-slim +FROM python:3.11-slim AS base LABEL maintainer="Soxoj " WORKDIR /app RUN pip install --no-cache-dir --upgrade pip @@ -15,4 +15,13 @@ COPY . . RUN YARL_NO_EXTENSIONS=1 python3 -m pip install --no-cache-dir . # For production use, set FLASK_HOST to a specific IP address for security ENV FLASK_HOST=0.0.0.0 + +# Web UI variant: auto-launches the web interface on $PORT +FROM base AS web +ENV PORT=5000 +EXPOSE 5000 +ENTRYPOINT ["sh", "-c", "exec maigret --web \"$PORT\""] + +# Default variant (last stage = `docker build .` target): CLI, backwards-compatible +FROM base AS cli ENTRYPOINT ["maigret"] diff --git a/README.md b/README.md index 8cb4c9c..786e15d 100644 --- a/README.md +++ b/README.md @@ -140,15 +140,27 @@ maigret username ### Docker +Two image variants are published: + +- `soxoj/maigret:latest` — CLI mode (default) +- `soxoj/maigret:web` — auto-launches the [web interface](#web-interface) + ```bash -# official image +# official image (CLI) docker pull soxoj/maigret -# usage +# CLI usage docker run -v /mydir:/app/reports soxoj/maigret:latest username --html +# Web UI (open http://localhost:5000) +docker run -p 5000:5000 soxoj/maigret:web + +# Web UI on a custom port +docker run -e PORT=8080 -p 8080:8080 soxoj/maigret:web + # manual build -docker build -t maigret . +docker build -t maigret . # CLI image (default target) +docker build --target web -t maigret-web . # Web UI image ``` ### Troubleshooting diff --git a/maigret/resources/db_meta.json b/maigret/resources/db_meta.json index 3974a67..335f0a1 100644 --- a/maigret/resources/db_meta.json +++ b/maigret/resources/db_meta.json @@ -1,6 +1,6 @@ { "version": 1, - "updated_at": "2026-04-25T16:11:27Z", + "updated_at": "2026-04-26T09:18:14Z", "sites_count": 3139, "min_maigret_version": "0.6.0", "data_sha256": "c51ecaa6c0736c5e1e7ca91aaf111445b3ac9ce9541a472d97db2dcc3ff8aa17", diff --git a/sites.md b/sites.md index a8c7555..735c2e0 100644 --- a/sites.md +++ b/sites.md @@ -3143,7 +3143,7 @@ Rank data fetched from Majestic Million by domains. 1. ![](https://www.google.com/s2/favicons?domain=https://flarum.es) [flarum.es (https://flarum.es)](https://flarum.es)*: top 100M, es, forum* 1. ![](https://www.google.com/s2/favicons?domain=https://forum.fibra.click) [forum.fibra.click (https://forum.fibra.click)](https://forum.fibra.click)*: top 100M, forum, it* -The list was updated at (2026-04-25) +The list was updated at (2026-04-26) ## Statistics Enabled/total sites: 2510/3139 = 79.96%