ChopFresh / Dockerfile
pranav8tripathi@gmail.com
initr
4a28655
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Optional build tools if you have native deps
RUN apk add --no-cache python3 make g++
# Install deps
COPY package*.json ./
# If you have a lockfile, prefer: RUN npm ci
RUN npm install
# Build
COPY . .
RUN npm run build
# Runtime stage
FROM node:20-alpine
WORKDIR /app
# Copy build output and preview config
COPY --from=builder /app/dist ./dist
COPY vite.preview.config.mjs ./vite.preview.config.mjs
# Minimal package setup and install vite for preview
RUN npm init -y && npm i --no-save vite@^5
# Ensure the "node" user can write to /app (Vite writes a temp file next to the config)
RUN chown -R node:node /app
USER node
ENV PORT=7860
EXPOSE 7860
# Run Vite preview with the minimal config
CMD ["node", "node_modules/vite/bin/vite.js", "preview", "--config", "./vite.preview.config.mjs"]