-
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
Draft
fengmk2
wants to merge
14
commits into
main
Choose a base branch
from
docker-image
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+997
−0
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
35b55a6
docs(rfc): add official Docker image RFC
fengmk2 2760ea5
docs(rfc): reflect install-script image build in Docker RFC
fengmk2 ea17dbe
feat(docker): add official Vite+ toolchain image
fengmk2 1e6450b
ci(docker): build a preview image from pkg.pr.new
fengmk2 49084e3
style(docker): apply oxfmt formatting to Docker docs and RFC
fengmk2 adcdbf6
refactor(docker): simplify image and speed up preview build
fengmk2 1250709
docs(rfc): link the docs-example verification repo
fengmk2 cd94960
docs(docker): prune prod deps in a separate stage
fengmk2 f546bc9
feat(docker): drop the baked default Node from the toolchain image
fengmk2 ea9542e
feat(docker): add Alpine (musl) toolchain image variant
fengmk2 8e331a6
docs(docker): note building a static SPA with the Alpine toolchain
fengmk2 c49f123
docs(docker): use 0.2.2 (first Docker release) in examples
fengmk2 9d628e1
docs(docker): COPY --chown=vp:vp in multi-stage examples
fengmk2 8bc91aa
ci(docker): post a sticky PR comment with preview image tags
fengmk2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # 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. | ||
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # 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. | ||
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you show the final size of the Docker image? Please display this metadata in a table.