44 lines
960 B
Docker
44 lines
960 B
Docker
# Production Dockerfile for MotoVaultPro Frontend
|
|
FROM node:20-alpine AS build
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install all dependencies (needed for build)
|
|
RUN npm install
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Production stage with nginx
|
|
FROM nginx:alpine
|
|
|
|
# Copy built assets from build stage
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
|
|
# Copy nginx configuration
|
|
COPY nginx.conf /etc/nginx/nginx.conf
|
|
|
|
# Create non-root user for nginx (nginx group already exists)
|
|
RUN adduser -S frontend -u 1001 -G nginx
|
|
|
|
# Change ownership of nginx directories
|
|
RUN chown -R frontend:nginx /var/cache/nginx && \
|
|
chown -R frontend:nginx /var/log/nginx && \
|
|
chown -R frontend:nginx /etc/nginx/conf.d
|
|
RUN touch /var/run/nginx.pid && \
|
|
chown -R frontend:nginx /var/run/nginx.pid
|
|
|
|
USER frontend
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Start nginx
|
|
CMD ["nginx", "-g", "daemon off;"] |