Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
.github
.gitignore
Dockerfile*
LICENSE
README.md
40 changes: 40 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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@v6

- name: Build image
run: docker build --tag getjs:test .

- name: Smoke test stdin extraction
run: |
printf '%s\n' '<script src="/app.js"></script>' \
| docker run --rm --interactive getjs:test \
| grep --fixed-strings --line-regexp '/app.js'
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down