cache node_modules if possible
This commit is contained in:
parent
5377fd711c
commit
596400e4de
1 changed files with 28 additions and 7 deletions
35
Dockerfile
35
Dockerfile
|
@ -1,4 +1,15 @@
|
|||
# Stage 1: Build the Vite React app
|
||||
# Stage 1: Dependencies install (cached if lockfile unchanged)
|
||||
FROM node:22-alpine AS deps
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Only copy dependency-related files to leverage cache
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
# Install dependencies
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
# Stage 2: Build the app
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
ARG VITE_API_URL
|
||||
|
@ -6,15 +17,25 @@ ENV VITE_API_URL=$VITE_API_URL
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY package.json /app
|
||||
COPY yarn.lock /app
|
||||
RUN yarn install
|
||||
# Copy deps from previous stage to cache node_modules
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY --from=deps /app/package.json ./package.json
|
||||
COPY --from=deps /app/yarn.lock ./yarn.lock
|
||||
|
||||
COPY . .
|
||||
# Copy rest of app
|
||||
COPY src/ ./src
|
||||
COPY public/ ./public
|
||||
COPY .env.production ./.env.production
|
||||
COPY index.html ./index.html
|
||||
COPY tsconfig.json ./tsconfig.json
|
||||
COPY tsconfig.app.json ./tsconfig.app.json
|
||||
COPY tsconfig.node.json ./tsconfig.node.json
|
||||
COPY vite.config.ts ./vite.config.ts
|
||||
|
||||
# Build the Vite app
|
||||
RUN yarn build
|
||||
|
||||
# Stage 2: Serve with Caddy
|
||||
# Stage 3: Serve with Caddy
|
||||
FROM caddy:alpine
|
||||
|
||||
# Copy built app to the web root
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue