Add DevSecOpsApp code with updated Jenkins pipeline for multi-environment deployment
This commit is contained in:
47
frontend/Dockerfile
Normal file
47
frontend/Dockerfile
Normal file
@@ -0,0 +1,47 @@
|
||||
# Multi-stage build for React frontend
|
||||
FROM node:18-alpine AS build
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy source code
|
||||
COPY public/ ./public/
|
||||
COPY src/ ./src/
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
# Production stage with Nginx
|
||||
FROM nginx:alpine AS production
|
||||
|
||||
# Copy custom nginx config
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Copy built React app
|
||||
COPY --from=build /app/build /usr/share/nginx/html
|
||||
|
||||
# Create a non-root user for nginx
|
||||
RUN addgroup -g 1001 -S nginxgroup && \
|
||||
adduser -S nginxuser -u 1001 -G nginxgroup
|
||||
|
||||
# Change ownership of nginx directories
|
||||
RUN chown -R nginxuser:nginxgroup /var/cache/nginx && \
|
||||
chown -R nginxuser:nginxgroup /var/log/nginx && \
|
||||
chown -R nginxuser:nginxgroup /etc/nginx/conf.d && \
|
||||
chown -R nginxuser:nginxgroup /usr/share/nginx/html
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1
|
||||
|
||||
# Expose port
|
||||
EXPOSE 80
|
||||
|
||||
# Start nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Reference in New Issue
Block a user