critical Docker & Self-Hosted Deployment

GitHub

Extract & Inline Critical-path CSS in HTML pages

10,180 stars JavaScript JavaScript 1 file ยท ~11,684 tokens #critical-css#critical-path-css#critical-path-styles#css#inline-css#inline-styles
1. Pull Image (DOCKERHUB) docker pull addyosmani/critical:latest
2. Docker Run (1-Click Launch) docker run -d --name critical --restart always addyosmani/critical:latest
3. Podman Run podman run -d --name critical --restart always addyosmani/critical:latest
4. Skopeo Inspect (Zero-Pull Manifest) skopeo inspect docker://docker.io/addyosmani/critical:latest
5. ORAS Pull (OCI Artifact) oras pull addyosmani/critical:latest
Dockerfile
# Official Playwright image ships Chromium plus every system dependency it needs,
# versioned and maintained upstream. PLAYWRIGHT_VERSION must match the playwright
# npm version below, because the bundled browsers are tied to a specific release.
ARG PLAYWRIGHT_VERSION=1.50.0
FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-noble

# Re-declare after FROM so the ARG is visible in the build stage.
ARG PLAYWRIGHT_VERSION

WORKDIR /app

# Build critical from the committed source instead of pulling from npm, so the image
# always matches this repo and never depends on a published (or unpublished) version.
COPY package.json ./
COPY cli.js ./
COPY src ./src

# Remove the repository-only prepare script, then install from a tarball so npm does
# not create a global symlink whose dependencies cannot be resolved from /app.
RUN npm pkg delete scripts.prepare \
	&& npm pack \
	&& npm install -g ./critical-*.tgz playwright@${PLAYWRIGHT_VERSION}

WORKDIR /site

CMD ["critical", "--help"]