From 179bc53693b3cb9c5ab5e212abf30692f514557b Mon Sep 17 00:00:00 2001 From: "Emmanuel A." Date: Mon, 22 Jun 2026 06:49:58 +0100 Subject: [PATCH 1/3] add a github action allowing to turn it into docker image --- .github/workflows/docker-build-push.yml | 98 +++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/docker-build-push.yml diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000..a81c9c7 --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -0,0 +1,98 @@ +name: Build & Push Docker Image + +on: + push: + branches: [main] + tags: ["v*"] + pull_request: + branches: [main] + workflow_dispatch: # lets you trigger manually from the GH UI + +env: + # --- Choose ONE registry block and delete the other --- + + # Option A: Google Artifact Registry + # GAR_LOCATION: us-central1 + # GAR_REPO: librecrawl # create this repo in GCP first + # IMAGE: ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ vars.GAR_REPO }}/librecrawl + + # Option B: Docker Hub (uncomment + delete Option A) + IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/librecrawl + +jobs: + build-and-push: + name: Build & Push + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # needed for Workload Identity auth to GCP + + steps: + # ── 1. Checkout ──────────────────────────────────────────────────────── + - name: Checkout code + uses: actions/checkout@v4 + + # ── 2. Set up Docker Buildx (multi-arch + cache support) ─────────────── + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # ══════════════════════════════════════════════════════════════════════ + # OPTION A — Google Artifact Registry + # Requires secrets: GCP_PROJECT_ID, GCP_WORKLOAD_IDENTITY_PROVIDER, + # GCP_SERVICE_ACCOUNT + # ══════════════════════════════════════════════════════════════════════ + # - name: Authenticate to Google Cloud + # uses: google-github-actions/auth@v2 + # with: + # workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} + # service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} + # + # - name: Configure Docker for Artifact Registry + # run: gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev --quiet + + # ══════════════════════════════════════════════════════════════════════ + # OPTION B — Docker Hub + # Requires secrets: DOCKERHUB_USERNAME, DOCKERHUB_TOKEN + # ══════════════════════════════════════════════════════════════════════ + - name: Log in to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # ── 3. Generate image tags ───────────────────────────────────────────── + # Produces tags like: + # yourusername/librecrawl:latest (on main push) + # yourusername/librecrawl:v1.2.3 (on tag push) + # yourusername/librecrawl:sha-abc1234 (always) + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,prefix=sha- + type=raw,value=latest,enable={{is_default_branch}} + + # ── 4. Build (and push on non-PR) ───────────────────────────────────── + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # Cache layers between runs so Playwright deps don't re-download every time + cache-from: type=gha + cache-to: type=gha,mode=max + # Uncomment for multi-arch (linux/arm64 is needed for Apple Silicon dev boxes + # or GCP Tau T2A instances): + # platforms: linux/amd64,linux/arm64 + + # ── 5. Print image digest for traceability ───────────────────────────── + - name: Image digest + run: echo "Pushed ${{ steps.meta.outputs.tags }}" \ No newline at end of file From 584c129a7908f02ae2b112c733aae2e02633b568 Mon Sep 17 00:00:00 2001 From: "Emmanuel A." Date: Mon, 22 Jun 2026 06:51:58 +0100 Subject: [PATCH 2/3] Update GitHub Actions workflow for Docker build --- .github/workflows/docker-build-push.yml | 61 +++++-------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index a81c9c7..7a365bb 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -6,93 +6,54 @@ on: tags: ["v*"] pull_request: branches: [main] - workflow_dispatch: # lets you trigger manually from the GH UI + workflow_dispatch: env: - # --- Choose ONE registry block and delete the other --- - - # Option A: Google Artifact Registry - # GAR_LOCATION: us-central1 - # GAR_REPO: librecrawl # create this repo in GCP first - # IMAGE: ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ vars.GAR_REPO }}/librecrawl - - # Option B: Docker Hub (uncomment + delete Option A) - IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/librecrawl + IMAGE: ghcr.io/${{ github.repository_owner }}/librecrawl jobs: build-and-push: - name: Build & Push + name: Build & Push to GHCR runs-on: ubuntu-latest permissions: contents: read - id-token: write # needed for Workload Identity auth to GCP + packages: write # this is all you need — no extra secrets steps: - # ── 1. Checkout ──────────────────────────────────────────────────────── - name: Checkout code uses: actions/checkout@v4 - # ── 2. Set up Docker Buildx (multi-arch + cache support) ─────────────── - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - # ══════════════════════════════════════════════════════════════════════ - # OPTION A — Google Artifact Registry - # Requires secrets: GCP_PROJECT_ID, GCP_WORKLOAD_IDENTITY_PROVIDER, - # GCP_SERVICE_ACCOUNT - # ══════════════════════════════════════════════════════════════════════ - # - name: Authenticate to Google Cloud - # uses: google-github-actions/auth@v2 - # with: - # workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} - # service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} - # - # - name: Configure Docker for Artifact Registry - # run: gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev --quiet - - # ══════════════════════════════════════════════════════════════════════ - # OPTION B — Docker Hub - # Requires secrets: DOCKERHUB_USERNAME, DOCKERHUB_TOKEN - # ══════════════════════════════════════════════════════════════════════ - - name: Log in to Docker Hub + - name: Log in to GitHub Container Registry if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - # ── 3. Generate image tags ───────────────────────────────────────────── - # Produces tags like: - # yourusername/librecrawl:latest (on main push) - # yourusername/librecrawl:v1.2.3 (on tag push) - # yourusername/librecrawl:sha-abc1234 (always) - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE }} tags: | - type=ref,event=branch + type=raw,value=latest,enable={{is_default_branch}} type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=sha,prefix=sha- - type=raw,value=latest,enable={{is_default_branch}} - # ── 4. Build (and push on non-PR) ───────────────────────────────────── - - name: Build and push Docker image + - name: Build and push uses: docker/build-push-action@v5 with: context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # Cache layers between runs so Playwright deps don't re-download every time cache-from: type=gha cache-to: type=gha,mode=max - # Uncomment for multi-arch (linux/arm64 is needed for Apple Silicon dev boxes - # or GCP Tau T2A instances): - # platforms: linux/amd64,linux/arm64 - # ── 5. Print image digest for traceability ───────────────────────────── - name: Image digest - run: echo "Pushed ${{ steps.meta.outputs.tags }}" \ No newline at end of file + run: echo "Pushed ${{ steps.meta.outputs.tags }}" From 97919946a447012c22c74d4e3eeeedbde13351eb Mon Sep 17 00:00:00 2001 From: "Emmanuel A." Date: Mon, 22 Jun 2026 07:03:38 +0100 Subject: [PATCH 3/3] Modify CMD in Dockerfile to run main.py with '--local' Updated CMD to include '--local' argument for main.py. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 06f084a..1114541 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,4 +67,4 @@ ENV PYTHONUNBUFFERED=1 # Run the application # The command is handled by docker-compose.yml -CMD ["python", "main.py"] +CMD ["python", "main.py", "--local"]