my-recipes/frontend/Dockerfile

33 lines
514 B
Docker

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node:20-alpine
WORKDIR /app
# Install a simple HTTP server to serve the built app
RUN npm install -g serve
# Copy built app from builder stage
COPY --from=builder /app/dist ./dist
EXPOSE 3000
# Serve the built app
CMD ["serve", "-s", "dist", "-l", "3000"]