- Change frontend port from 80 to 8847 and backend port from 3001 to 9173 in .env.example - Replace nginx stage in frontend Dockerfile with node alpine and serve for static hosting - Remove nginx.conf and related configuration for frontend static serving - Update docker-compose ports and healthcheck URLs to match new port assignments - Adjust server Dockerfile to expose new backend port 9173 and update healthcheck URL - Create non-root user in frontend Dockerfile and run serve command on port 8847 - Update healthcheck commands to use wget on new ports for both frontend and backend
51 lines
1.0 KiB
Docker
51 lines
1.0 KiB
Docker
# Frontend Dockerfile (Coolify Optimized - Static Server)
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Build arguments for environment variables
|
|
ARG VITE_MS_CLIENT_ID
|
|
ARG VITE_GOOGLE_CLIENT_ID
|
|
ARG VITE_API_URL
|
|
|
|
# Set as environment variables for build
|
|
ENV VITE_MS_CLIENT_ID=$VITE_MS_CLIENT_ID
|
|
ENV VITE_GOOGLE_CLIENT_ID=$VITE_GOOGLE_CLIENT_ID
|
|
ENV VITE_API_URL=$VITE_API_URL
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the app
|
|
RUN npm run build
|
|
|
|
# Production stage - lightweight static server
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Install serve for static file hosting
|
|
RUN npm install -g serve
|
|
|
|
# Copy built assets
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
adduser -S nodejs -u 1001
|
|
USER nodejs
|
|
|
|
EXPOSE 8847
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD wget -q --spider http://localhost:8847 || exit 1
|
|
|
|
# Serve static files with SPA fallback
|
|
CMD ["serve", "-s", "dist", "-l", "8847"]
|