From 8de172f089c708bcb76b3fac27684d7e8966eaf6 Mon Sep 17 00:00:00 2001 From: 003random <003random@protonmail.com> Date: Sun, 30 Aug 2026 00:24:38 +0200 Subject: [PATCH 1/2] Add Docker support for v2 --- .dockerignore | 6 ++++++ .github/workflows/docker.yml | 40 ++++++++++++++++++++++++++++++++++++ Dockerfile | 27 ++++++++++++++++++++++++ README.md | 35 +++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c552e57 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.github +.gitignore +Dockerfile* +LICENSE +README.md diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..7a65ca0 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,40 @@ +name: Docker + +on: + pull_request: + paths: + - ".dockerignore" + - ".github/workflows/docker.yml" + - "Dockerfile" + - "**/*.go" + - "go.mod" + - "go.sum" + push: + branches: + - master + paths: + - ".dockerignore" + - ".github/workflows/docker.yml" + - "Dockerfile" + - "**/*.go" + - "go.mod" + - "go.sum" + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Build image + run: docker build --tag getjs:test . + + - name: Smoke test stdin extraction + run: | + printf '%s\n' '' \ + | docker run --rm --interactive getjs:test \ + | grep --fixed-strings --line-regexp '/app.js' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..02dc6bf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# syntax=docker/dockerfile:1 + +FROM --platform=$BUILDPLATFORM golang:1.27.0-bookworm AS build + +ARG TARGETOS +ARG TARGETARCH + +WORKDIR /src + +COPY go.mod go.sum ./ +RUN go mod download && go mod verify + +COPY . . +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \ + go build -trimpath -ldflags="-s -w" -o /out/getjs . + +FROM scratch + +LABEL org.opencontainers.image.source="https://github.com/003random/getJS" \ + org.opencontainers.image.description="Extract JavaScript sources from URLs and HTTP responses" \ + org.opencontainers.image.licenses="MIT" + +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=build --chown=65532:65532 /out/getjs /getjs + +USER 65532:65532 +ENTRYPOINT ["/getjs"] diff --git a/README.md b/README.md index 87b509f..419cd9d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ This is a powerful tool for extracting JavaScript sources from URLs, web pages, ## Table of Contents - [Installation](#installation) +- [Docker](#docker) - [CLI Usage](#cli-usage) - [Options](#options) - [Examples](#examples) @@ -33,6 +34,40 @@ To install `getJS`, use the following command: `go install github.com/003random/getJS/v2@latest` +## Docker + +Build the image from the repository root: + +```sh +docker build -t getjs:local . +``` + +Run getJS against a URL: + +```sh +docker run --rm getjs:local -url https://example.com +``` + +When piping a URL or HTTP response into the container, keep stdin open with +`--interactive`: + +```sh +curl https://example.com | docker run --rm --interactive getjs:local +``` + +Mount URL-list files read-only and refer to them by their container path: + +```sh +docker run --rm --volume "${PWD}:/data:ro" getjs:local -input /data/urls.txt +``` + +Results are written to stdout by default, so they can be saved on the host +without granting the container write access: + +```sh +docker run --rm getjs:local -url https://example.com > results.txt +``` + ## CLI Usage ### Options From 53c0070e6fe539ca84e2869ac8934a5d00112e62 Mon Sep 17 00:00:00 2001 From: 003random <003random@protonmail.com> Date: Sun, 30 Aug 2026 00:36:39 +0200 Subject: [PATCH 2/2] Update checkout action to v6 --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7a65ca0..a658a6e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Build image run: docker build --tag getjs:test .