diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2b4d030 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +node_modules +dist +.git +.github +.claude +docs +*.md +!README.md +coverage diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..b8f8c2a --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,62 @@ +name: Docker image + +on: + push: + tags: ['v*'] # a release tag publishes ghcr.io/ajithakdev/toolglass + pull_request: + branches: [main] + paths: ['Dockerfile', 'docker/**', '.dockerignore', '.github/workflows/docker.yml'] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} # never cancel a release publish + +jobs: + image: + runs-on: ubuntu-latest + timeout-minutes: 20 + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - name: Set up QEMU + uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 + + - name: Set up Buildx + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + + - name: Log in to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Image tags + id: meta + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=ref,event=pr + + - name: Build and push + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 + 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2f64c..fd1e859 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to Toolglass. The format follows [Keep a Changelog](https:// ## [Unreleased] ### Added +- Docker image for self-hosting: `docker run -p 8080:8080 ghcr.io/ajithakdev/toolglass`. Unprivileged nginx serving the static site, for amd64 and arm64, published to GHCR on every release. - A "support it on Ko-fi" link in the Open source section of the About page, plus the UPI ID for India. It is a plain link, so no Ko-fi script loads. - Support section in the README with Ko-fi and a UPI QR code. - User-Agent Parser: paste a string to see the browser, version, engine, operating system, device, and whether it looks like a bot. Chromium also shows Client Hints for the current browser. Copy the result as JSON (#201, thanks @Dtzul04). diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..057adf9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# Self-hosted Toolglass: build the static site, then serve it with unprivileged nginx on port 8080. +FROM --platform=$BUILDPLATFORM docker.io/library/node:22-alpine AS build +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci --no-audit --no-fund +COPY . . +RUN npm run build + +FROM docker.io/nginxinc/nginx-unprivileged:1.29-alpine +COPY docker/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html +EXPOSE 8080 +HEALTHCHECK --interval=30s --timeout=3s CMD wget -q -O /dev/null http://127.0.0.1:8080/ || exit 1 diff --git a/README.md b/README.md index 317ce81..833e105 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,13 @@ Every link and how-to is in [RESOURCES-AND-GUIDE.md](RESOURCES-AND-GUIDE.md). -**41 free tools that run entirely in your browser, for developers and everyone else.** +**42 free tools that run entirely in your browser, for developers and everyone else. Nothing you paste or open is uploaded.** + +An open-source alternative to upload-first sites like iLovePDF, TinyPNG, jwt.io and online converters. Use it online, or run your own copy with one command: + +```bash +docker run -d -p 8080:8080 ghcr.io/ajithakdev/toolglass +``` [![License: MIT](https://img.shields.io/badge/License-MIT-blueviolet.svg)](LICENSE) [![React](https://img.shields.io/badge/React-19-149eca.svg)](https://react.dev) @@ -52,6 +58,31 @@ There are tools for everyday jobs (word counter, unit converter, image compresso --- +## 🐳 Self-host with Docker + +The image is the static site served by unprivileged nginx, about 60 MB, for `amd64` and `arm64` (Raspberry Pi works). It has no backend and makes no outgoing requests. + +```bash +docker run -d --name toolglass -p 8080:8080 --restart unless-stopped ghcr.io/ajithakdev/toolglass +``` + +Open http://localhost:8080. With Docker Compose: + +```yaml +services: + toolglass: + image: ghcr.io/ajithakdev/toolglass:latest + ports: + - "8080:8080" + restart: unless-stopped +``` + +Tags: `latest`, each release (`1.3.0`) and each minor line (`1.3`). To build it yourself: `docker build -t toolglass .`. Serve it at the root of a domain or subdomain (`tools.example.com`); a sub-path like `example.com/tools/` is not supported yet. Installing it as an app and offline use need HTTPS, so put it behind your usual reverse proxy. + +What it changes on your system: one container listening on the port you choose. It writes nothing to disk; tool data stays in each visitor's browser storage. + +--- + ## 🛠️ Local Development Toolglass uses standard modern frontend tooling (React 19, TypeScript, Vite, Vitest): diff --git a/RESOURCES-AND-GUIDE.md b/RESOURCES-AND-GUIDE.md index f7ca5ac..1b09b93 100644 --- a/RESOURCES-AND-GUIDE.md +++ b/RESOURCES-AND-GUIDE.md @@ -30,6 +30,7 @@ Every link for Toolglass, what it is for, how to contribute, and how to run and | https://github.com/ajithakdev/toolglass | Source code and discussions | | https://github.com/ajithakdev/toolglass/issues | Bug reports, feature requests, and tool ideas | | https://github.com/ajithakdev/toolglass/actions/workflows/ci-cd.yml | CI verify and GitHub Pages deploy workflow | +| https://github.com/ajithakdev/toolglass/pkgs/container/toolglass | Docker image for self-hosting (published on each release tag) | | https://github.com/ajithakdev/toolglass/releases | Published releases and release notes | ## Accounts @@ -55,7 +56,8 @@ Every link for Toolglass, what it is for, how to contribute, and how to run and | Check lint | `npm run lint` or `npm run lint -- --fix` | | Build and type-check | `npm run build` | | Preview build | `npm run preview` | -| Deploy | Push a `vX.Y.Z` tag (the release does this). Merges to `main` are checked but not deployed | +| Run the Docker image locally | `docker build -t toolglass .` then `docker run -p 8080:8080 toolglass` (Podman works the same) | +| Deploy | Push a `vX.Y.Z` tag (the release does this). The same tag also publishes the Docker image to GHCR. Merges to `main` are checked but not deployed | | Release (every Sunday) | Patch if the week had only fixes, minor if it added a tool or feature. Move `## [Unreleased]` in `CHANGELOG.md` under `## [X.Y.Z] - date`, bump `package.json`, commit `chore: release vX.Y.Z`, tag `vX.Y.Z`, push the tag, then `gh release create` with that changelog section | | Hotfix (broken tool, security) | Same release steps the same day, as a patch | | Redeploy without a release | Actions, CI/CD, "Run workflow" on `main` | diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..cc3a931 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,31 @@ +server { + listen 8080; + server_name _; + root /usr/share/nginx/html; + server_tokens off; + + add_header X-Content-Type-Options nosniff always; + add_header Referrer-Policy no-referrer always; + add_header X-Frame-Options DENY always; + + # /tools/json is served from tools/json.html, like GitHub Pages does + location / { + try_files $uri $uri.html $uri/ =404; + } + + # Hashed bundles never change, so browsers can keep them for a year + location /assets/ { + add_header Cache-Control "public, max-age=31536000, immutable"; + add_header X-Content-Type-Options nosniff always; + try_files $uri =404; + } + + # The service worker must be re-checked on every visit so updates arrive + location = /sw.js { + add_header Cache-Control "no-cache"; + add_header X-Content-Type-Options nosniff always; + } + + # Unknown paths get the app shell, which shows the in-app "not found" page + error_page 404 /404.html; +} diff --git a/docs/CODEMAP.md b/docs/CODEMAP.md index 203b0b9..e7a55bf 100644 --- a/docs/CODEMAP.md +++ b/docs/CODEMAP.md @@ -1,6 +1,6 @@ # Toolglass code map -Mapped at commit: `a2bd9e2` (v1.2.0 release, 2026-11-10; v1.2 files were mapped on the branch). Earlier note: `511327b` plus branch `test/138-timestamp-json-to-ts` (2026-10-26). Sections not touched by that branch were last checked at `6811fb6`. Timestamp and JSON-to-TS sections updated at `41d6999` (#196, 2026-10-31). +Mapped at commit: `e3077a3` (Docker files added on `feat/docker`, 2026-11-10). Before that: `a2bd9e2` (v1.2.0 release, 2026-11-10; v1.2 files were mapped on the branch). Earlier note: `511327b` plus branch `test/138-timestamp-json-to-ts` (2026-10-26). Sections not touched by that branch were last checked at `6811fb6`. Timestamp and JSON-to-TS sections updated at `41d6999` (#196, 2026-10-31). Check for drift before trusting this file: `git diff --stat c7cd085..HEAD -- src` @@ -38,6 +38,9 @@ index.html | `eslint.config.js` (26) | Flat config. Several `react-hooks/*` rules turned off (set-state-in-effect, purity, refs, error-boundaries, set-state-in-render). | | `index.html` | Content-Security-Policy meta, meta, OG tags, JSON-LD, pre-paint theme script. Fonts are self-hosted Geist and Geist Mono (see `index.css`). | | `.github/ISSUE_TEMPLATE/` | Issue forms: `bug_report.yml`, `feature_request.yml`; `config.yml` turns off blank issues and links Discussions, SECURITY.md, and the site. Tool-request links in `ToolsHub.tsx` and `About.tsx` open `feature_request.yml` with `template=`. | +| `Dockerfile` | Two stages: `npm ci` and `npm run build` on the build platform, then `nginx-unprivileged` serving `dist` on port 8080. `.dockerignore` keeps `node_modules`, `dist`, `.git` and docs out of the context. | +| `docker/nginx.conf` | Serves `/tools/` from `tools/.html` like GitHub Pages, `404.html` for unknown paths, a year of cache for `/assets/`, `no-cache` for `sw.js`, plus nosniff, no-referrer and frame-deny headers. | +| `.github/workflows/docker.yml` | On a `v*` tag: builds amd64 and arm64 and pushes `ghcr.io/ajithakdev/toolglass` tagged `X.Y.Z`, `X.Y` and `latest`. On a PR that touches the Docker files: builds only. | | `.github/workflows/ci-cd.yml` | `verify` job: `npm ci`, lint, build, test, upload Pages artifact. `deploy` job: Pages, only on a `v*` tag push or a manual run; it alone has `pages`/`id-token` write. | | `scripts/gen-keccak-permute.py` | Prints the unrolled Keccak `permute` for `src/tools/hash/hash.ts`. Only needed if that function is ever regenerated. | | `public/` | favicon.svg, icon-192.png, icon-512.png, og-image.png, robots.txt, sitemap.xml. | diff --git a/docs/NEXT.md b/docs/NEXT.md index a465996..0588370 100644 --- a/docs/NEXT.md +++ b/docs/NEXT.md @@ -55,7 +55,7 @@ Positioning to use everywhere: **"Open-source tools that never upload your files - [x] Fix duplicated description text (2026-11-10). Descriptions now also end with "A private alternative to ", and a test blocks dashes and repeats. - [ ] Give every tool page a short "How to use" and "Is my file uploaded? No" section in plain words. That's what ranks for long-tail searches and what people want to read. - [ ] One Open Graph image per tool (generated at build time), so shared links show a proper card. -- [ ] **Docker image plus BASE_PATH** (moved up from Phase C): a small nginx image on GHCR (free for public repos), one `docker run -p 8080:80 ghcr.io/ajithakdev/toolglass` line in the README, and a compose example. This is the entry ticket to r/selfhosted and awesome-selfhosted. +- [ ] **Docker image** (moved up from Phase C; built on branch `feat/docker`, first image publishes with the v1.3.0 tag; sub-path hosting via BASE_PATH left for later): a small nginx image on GHCR (free for public repos), one `docker run -p 8080:80 ghcr.io/ajithakdev/toolglass` line in the README, and a compose example. This is the entry ticket to r/selfhosted and awesome-selfhosted. - [ ] README top: one GIF (compress an image with DevTools open, 0 requests), the "replaces iLovePDF / TinyPNG / online converters" line, the live link, the Docker line. Most visitors decide in the first screen. - [ ] Decide on counting (**your call**): today GitHub Pages serves the site directly (DNS only on Cloudflare). Turning on Cloudflare's free proxy for the subdomain would give request counts in its dashboard with no script on the page, so the "no analytics" promise holds. It needs a careful switch (SSL mode Full) so HTTPS doesn't break. Say yes or no.