Backup: 2025-06-07 19:48 - Script test
[Restore from backup: vip-coordinator-backup-2025-06-07-19-48-script-test]
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# Multi-stage build for development and production
|
||||
FROM node:22-alpine AS base
|
||||
FROM node:22-slim AS base
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -13,9 +13,61 @@ COPY . .
|
||||
EXPOSE 5173
|
||||
CMD ["npm", "run", "dev"]
|
||||
|
||||
# Production stage
|
||||
FROM base AS production
|
||||
RUN npm install
|
||||
# Build stage
|
||||
FROM base AS build
|
||||
|
||||
# Accept build argument for API URL
|
||||
ARG VITE_API_URL
|
||||
ENV VITE_API_URL=$VITE_API_URL
|
||||
|
||||
# Install build dependencies for native modules (Debian-based)
|
||||
RUN apt-get update && apt-get install -y \
|
||||
python3 \
|
||||
make \
|
||||
g++ \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production && npm cache clean --force
|
||||
RUN npm install typescript @vitejs/plugin-react vite
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
EXPOSE 5173
|
||||
CMD ["npm", "run", "dev"]
|
||||
|
||||
# Build the application with environment variable available
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM nginx:alpine AS production
|
||||
|
||||
# Copy custom nginx configuration
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Copy built application from build stage
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
# Create non-root user for security
|
||||
RUN addgroup -g 1001 -S appuser && \
|
||||
adduser -S appuser -u 1001 -G appuser
|
||||
|
||||
# Set proper permissions and create necessary directories
|
||||
RUN chown -R appuser:appuser /usr/share/nginx/html && \
|
||||
chown -R appuser:appuser /var/cache/nginx && \
|
||||
chown -R appuser:appuser /var/log/nginx && \
|
||||
chown -R appuser:appuser /etc/nginx/conf.d && \
|
||||
mkdir -p /tmp/nginx && \
|
||||
chown -R appuser:appuser /tmp/nginx && \
|
||||
touch /tmp/nginx/nginx.pid && \
|
||||
chown appuser:appuser /tmp/nginx/nginx.pid
|
||||
|
||||
# Switch to non-root user
|
||||
USER appuser
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# Start nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user