-
Notifications
You must be signed in to change notification settings - Fork 215
feat(docker): official Vite+ toolchain image #1944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
35b55a6
2760ea5
ea17dbe
1e6450b
49084e3
adcdbf6
1250709
cd94960
f546bc9
ea9542e
8e331a6
c49f123
9d628e1
8bc91aa
74b6dc9
901e972
5bfb671
d36ba17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| # | ||
| # Official Vite+ toolchain image. | ||
| # | ||
| # Bundles the `vp` CLI for the build, CI, and development phases. This is NOT a | ||
| # production runtime image: it ships the full toolchain (vite, rolldown, vitest, | ||
| # oxlint, ...) and is meant for use as a build stage, CI image, or devcontainer. | ||
| # | ||
| # For production, use the documented multi-stage pattern (see docs/guide/docker.md) | ||
| # where this image builds the app and the exact Node.js resolved from | ||
| # `.node-version` is copied into a small, vp-free runtime stage. | ||
|
|
||
| FROM debian:bookworm-slim | ||
|
|
||
| LABEL org.opencontainers.image.source="https://github.com/voidzero-dev/vite-plus" \ | ||
| org.opencontainers.image.description="Vite+ toolchain image (vp CLI) for build, CI, and development" \ | ||
| org.opencontainers.image.licenses="MIT" | ||
|
|
||
| # Version of vp to install. Override at build time: | ||
| # docker build --build-arg VP_VERSION=1.4.2 . | ||
| ARG VP_VERSION=latest | ||
|
|
||
| # Optional: build a preview image from a pkg.pr.new build instead of npm. | ||
| # Set to a PR number or commit SHA; when set it overrides VP_VERSION. | ||
| # docker build --build-arg VP_PR_VERSION=1569 . | ||
| ARG VP_PR_VERSION= | ||
|
|
||
| # Toolchain image: include git and a C/C++ build toolchain so native addons | ||
| # (for example better-sqlite3 or sharp) can compile during `vp install`. | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| ca-certificates \ | ||
| curl \ | ||
| git \ | ||
| build-essential \ | ||
| python3 \ | ||
| pkg-config \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && useradd --create-home --shell /bin/bash vp | ||
|
|
||
| # Run as a non-root user by default (mirrors oven/bun's `bun` and Deno's `deno`). | ||
| USER vp | ||
|
|
||
| ENV VP_HOME=/home/vp/.vite-plus \ | ||
| PATH=/home/vp/.vite-plus/bin:$PATH | ||
|
|
||
| # Install the vp global CLI. The installer downloads the platform package from | ||
| # npm (or from pkg.pr.new when VP_PR_VERSION is set). Node.js itself is | ||
| # provisioned per-project by vp at build time, honoring `.node-version` / | ||
| # `engines.node` / `devEngines.runtime`. | ||
| # | ||
| # The installer pre-provisions a default Node.js (~190 MB). Drop it: each project | ||
| # downloads its own pinned Node at build time, so the default is dead weight in a | ||
| # builder image. The node/npm/npx shims remain and fetch the right version on | ||
| # first use. | ||
| # | ||
| # Keep this install line in sync with docker/Dockerfile.alpine. | ||
| RUN curl -fsSL https://vite.plus | VP_VERSION="${VP_VERSION}" VP_PR_VERSION="${VP_PR_VERSION}" bash \ | ||
| && vp --version \ | ||
| && rm -rf "$VP_HOME/js_runtime" | ||
|
|
||
| WORKDIR /app | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When downstream Dockerfiles follow the new guide and run Useful? React with 👍 / 👎. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| # | ||
| # Alpine (musl) variant of the official Vite+ toolchain image. | ||
| # | ||
| # Smaller base than the Debian image, but note the tradeoffs: | ||
| # - Vite+ installs Node.js from the unofficial musl builds | ||
| # (unofficial-builds.nodejs.org), which are NOT PGP-signed. | ||
| # - Some native addons need musl prebuilds or source compilation. | ||
| # - A musl Node.js binary only runs on a musl base, so pair this builder with | ||
| # an Alpine runtime stage (see docs/guide/docker.md). | ||
| # | ||
| # Prefer the Debian image (ghcr.io/voidzero-dev/vite-plus) unless you | ||
| # specifically need Alpine/musl. | ||
|
|
||
| FROM alpine:3.21 | ||
|
|
||
| LABEL org.opencontainers.image.source="https://github.com/voidzero-dev/vite-plus" \ | ||
| org.opencontainers.image.description="Vite+ toolchain image (vp CLI, Alpine/musl) for build, CI, and development" \ | ||
| org.opencontainers.image.licenses="MIT" | ||
|
|
||
| # Version of vp to install. Override at build time: | ||
| # docker build --build-arg VP_VERSION=1.4.2 -f docker/Dockerfile.alpine . | ||
| ARG VP_VERSION=latest | ||
|
|
||
| # Optional: build a preview image from a pkg.pr.new build instead of npm. | ||
| ARG VP_PR_VERSION= | ||
|
|
||
| # build-base + python3 let native addons compile from source on musl. | ||
| RUN apk add --no-cache \ | ||
| bash \ | ||
| ca-certificates \ | ||
| curl \ | ||
| git \ | ||
| tar \ | ||
| build-base \ | ||
| python3 \ | ||
| && adduser -D -s /bin/bash vp | ||
|
|
||
| # Run as a non-root user by default (mirrors oven/bun's `bun` and Deno's `deno`). | ||
| USER vp | ||
|
|
||
| ENV VP_HOME=/home/vp/.vite-plus \ | ||
| PATH=/home/vp/.vite-plus/bin:$PATH | ||
|
|
||
| # Install the vp global CLI (musl build), then drop the pre-provisioned default | ||
| # Node.js: each project provisions its own pinned Node at build time, so the | ||
| # default is dead weight. The node/npm/npx shims remain and fetch the right | ||
| # version on first use. | ||
| # | ||
| # Keep this install line in sync with docker/Dockerfile. | ||
| RUN curl -fsSL https://vite.plus | VP_VERSION="${VP_VERSION}" VP_PR_VERSION="${VP_PR_VERSION}" bash \ | ||
| && vp --version \ | ||
| && rm -rf "$VP_HOME/js_runtime" | ||
|
|
||
| WORKDIR /app |
Uh oh!
There was an error while loading. Please reload this page.