vinxi cache in docker build
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
node_modules
|
node_modules
|
||||||
Dockerfile
|
Dockerfile
|
||||||
Makefile
|
Makefile
|
||||||
pnpm-lock.yaml
|
|
||||||
README.md
|
README.md
|
||||||
.output
|
.output
|
||||||
.vinxi
|
.vinxi
|
||||||
|
|||||||
47
Dockerfile
47
Dockerfile
@@ -1,12 +1,45 @@
|
|||||||
|
# === STAGE 1: Build & Dependencies ===
|
||||||
|
FROM node:22 AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install pnpm and enable corepack
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
|
# Copy the lockfile and package.json to leverage caching
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
# Use a cache mount to persist the pnpm store across builds.
|
||||||
|
# The 'pnpm install' command will use this persistent cache.
|
||||||
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy the rest of the application files
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Use a second cache mount for the Vinxi build artifacts.
|
||||||
|
# This tells Docker to mount a persistent cache directory to a build-cache location.
|
||||||
|
# The `pnpm run build` command will now use this cache for incremental builds.
|
||||||
|
# We'll assume a `.vinxi` or `.cache` directory for this example.
|
||||||
|
RUN --mount=type=cache,target=/app/.vinxi \
|
||||||
|
pnpm run build
|
||||||
|
|
||||||
|
# === STAGE 2: Production Final Image ===
|
||||||
FROM node:22-alpine
|
FROM node:22-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Enable corepack and install only production dependencies
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
# This install can also use the cache mount to avoid re-downloading
|
||||||
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \
|
||||||
|
pnpm install --frozen-lockfile --prod
|
||||||
|
|
||||||
|
# Copy the compiled assets and lockfile from the builder stage
|
||||||
|
COPY --from=builder /app/.output ./.output
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
COPY package.json ./
|
CMD ["pnpm", "start"]
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
CMD ["npm", "run", "start"]
|
|
||||||
7
Makefile
7
Makefile
@@ -1,7 +1,12 @@
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
build:
|
build:
|
||||||
docker build --platform linux/arm64 -t games .
|
sudo docker buildx build --load \
|
||||||
|
--cache-from=type=local,src=/var/cache/docker-build \
|
||||||
|
--cache-to=type=local,dest=/var/cache/docker-build \
|
||||||
|
--platform linux/arm64 \
|
||||||
|
--tag games .
|
||||||
|
|
||||||
|
|
||||||
start:
|
start:
|
||||||
sudo docker run -p $(PORT):3000 -t games
|
sudo docker run -p $(PORT):3000 -t games
|
||||||
|
|||||||
Reference in New Issue
Block a user