mirror of
https://github.com/sstent/AICyclingCoach.git
synced 2026-01-25 16:41:58 +00:00
39 lines
815 B
Docker
39 lines
815 B
Docker
# Build stage
|
|
FROM node:20-alpine AS build
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package.json and package-lock.json
|
|
COPY frontend/package*.json ./
|
|
|
|
# Install all dependencies including devDependencies
|
|
RUN npm install --include=dev
|
|
|
|
# Copy source code
|
|
COPY frontend/ .
|
|
|
|
# Run tests and build application
|
|
RUN npm test && npm run build
|
|
|
|
# Production stage
|
|
FROM node:20-alpine AS production
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy build artifacts and dependencies
|
|
COPY --from=build /app/package*.json ./
|
|
COPY --from=build /app/.next ./.next
|
|
COPY --from=build /app/node_modules ./node_modules
|
|
COPY --from=build /app/public ./public
|
|
|
|
# Create non-root user
|
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
USER appuser
|
|
|
|
# Expose application port
|
|
EXPOSE 3000
|
|
|
|
# Run application
|
|
CMD ["npm", "start"] |