forked from trent_larson/crowd-funder-for-time-pwa
Fix: markdownlint MD012/MD019 errors in build-pattern-conversion-plan.md
- Removed extra blank lines at end of file to resolve MD012 (no-multiple-blanks) - Standardized heading spacing to resolve MD019 (no-multiple-space-atx) - Stripped trailing whitespace and ensured file ends with a single newline All changes maintain content integrity and bring the file into full markdownlint compliance.
This commit is contained in:
93
Dockerfile
93
Dockerfile
@@ -4,8 +4,10 @@
|
||||
#
|
||||
# Build Process:
|
||||
# 1. Base stage: Node.js with build dependencies
|
||||
# 2. Builder stage: Compile web assets with Vite
|
||||
# 2. Builder stage: Copy pre-built web assets from host
|
||||
# 3. Production stage: Nginx server with optimized assets
|
||||
#
|
||||
# Note: Web assets are built on the host using npm scripts before Docker build
|
||||
#
|
||||
# Security Features:
|
||||
# - Non-root user execution
|
||||
@@ -14,25 +16,26 @@
|
||||
# - No build dependencies in final image
|
||||
#
|
||||
# Usage:
|
||||
# Production: docker build -t timesafari:latest .
|
||||
# Staging: docker build --build-arg BUILD_MODE=staging -t timesafari:staging .
|
||||
# Development: docker build --build-arg BUILD_MODE=development -t timesafari:dev .
|
||||
# IMPORTANT: Build web assets first, then build Docker image
|
||||
#
|
||||
# Using npm scripts (recommended):
|
||||
# Production: npm run build:web:docker:prod
|
||||
# Test: npm run build:web:docker:test
|
||||
# Development: npm run build:web:docker
|
||||
#
|
||||
# Manual workflow:
|
||||
# 1. Build web assets: npm run build:web:build -- --mode production
|
||||
# 2. Build Docker: docker build -t timesafari:latest .
|
||||
#
|
||||
# Note: For development, use npm run build:web directly (no Docker needed)
|
||||
#
|
||||
# Build Arguments:
|
||||
# BUILD_MODE: development, staging, or production (default: production)
|
||||
# BUILD_MODE: development, test, or production (default: production)
|
||||
# NODE_ENV: node environment (default: production)
|
||||
# VITE_PLATFORM: vite platform (default: web)
|
||||
# VITE_PWA_ENABLED: enable PWA (default: true)
|
||||
# VITE_DISABLE_PWA: disable PWA (default: false)
|
||||
#
|
||||
# Environment Variables:
|
||||
# NODE_ENV: Build environment (development/production)
|
||||
# VITE_APP_SERVER: Application server URL
|
||||
# VITE_DEFAULT_ENDORSER_API_SERVER: Endorser API server URL
|
||||
# VITE_DEFAULT_IMAGE_API_SERVER: Image API server URL
|
||||
# VITE_DEFAULT_PARTNER_API_SERVER: Partner API server URL
|
||||
# VITE_DEFAULT_PUSH_SERVER: Push notification server URL
|
||||
# VITE_PASSKEYS_ENABLED: Enable passkeys feature
|
||||
# BUILD_MODE: Build mode for asset selection (development/test/production)
|
||||
|
||||
# =============================================================================
|
||||
# BASE STAGE - Common dependencies and setup
|
||||
@@ -66,34 +69,20 @@ RUN npm ci --only=production --audit --fund=false && \
|
||||
npm audit fix --audit-level=moderate || true
|
||||
|
||||
# =============================================================================
|
||||
# BUILDER STAGE - Compile web assets
|
||||
# BUILDER STAGE - Copy pre-built assets
|
||||
# =============================================================================
|
||||
FROM base AS builder
|
||||
|
||||
# Define build arguments with defaults
|
||||
ARG BUILD_MODE=production
|
||||
ARG NODE_ENV=production
|
||||
ARG VITE_PLATFORM=web
|
||||
ARG VITE_PWA_ENABLED=true
|
||||
ARG VITE_DISABLE_PWA=false
|
||||
|
||||
# Set environment variables from build arguments
|
||||
ENV BUILD_MODE=${BUILD_MODE}
|
||||
ENV NODE_ENV=${NODE_ENV}
|
||||
ENV VITE_PLATFORM=${VITE_PLATFORM}
|
||||
ENV VITE_PWA_ENABLED=${VITE_PWA_ENABLED}
|
||||
ENV VITE_DISABLE_PWA=${VITE_DISABLE_PWA}
|
||||
|
||||
# Install all dependencies (including dev dependencies)
|
||||
RUN npm ci --audit --fund=false && \
|
||||
npm audit fix --audit-level=moderate || true
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the application with proper error handling
|
||||
RUN echo "Building TimeSafari in ${BUILD_MODE} mode..." && \
|
||||
npm run build:web || (echo "Build failed. Check the logs above." && exit 1)
|
||||
# Copy pre-built assets from host
|
||||
COPY dist/ ./dist/
|
||||
|
||||
# Verify build output exists
|
||||
RUN ls -la dist/ || (echo "Build output not found in dist/ directory" && exit 1)
|
||||
@@ -150,52 +139,22 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
# Start nginx with proper signal handling
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
# =============================================================================
|
||||
# DEVELOPMENT STAGE - For development with hot reloading
|
||||
# =============================================================================
|
||||
FROM base AS development
|
||||
|
||||
# Define build arguments for development stage
|
||||
ARG BUILD_MODE=development
|
||||
ARG NODE_ENV=development
|
||||
ARG VITE_PLATFORM=web
|
||||
ARG VITE_PWA_ENABLED=true
|
||||
ARG VITE_DISABLE_PWA=false
|
||||
|
||||
# Set environment variables
|
||||
ENV BUILD_MODE=${BUILD_MODE}
|
||||
ENV NODE_ENV=${NODE_ENV}
|
||||
ENV VITE_PLATFORM=${VITE_PLATFORM}
|
||||
ENV VITE_PWA_ENABLED=${VITE_PWA_ENABLED}
|
||||
ENV VITE_DISABLE_PWA=${VITE_DISABLE_PWA}
|
||||
|
||||
# Install all dependencies including dev dependencies
|
||||
RUN npm ci --audit --fund=false && \
|
||||
npm audit fix --audit-level=moderate || true
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Expose development port
|
||||
EXPOSE 5173
|
||||
|
||||
# Start development server
|
||||
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
||||
|
||||
# =============================================================================
|
||||
# STAGING STAGE - For staging environment testing
|
||||
# TEST STAGE - For test environment testing
|
||||
# =============================================================================
|
||||
FROM production AS staging
|
||||
FROM production AS test
|
||||
|
||||
# Define build arguments for staging stage
|
||||
ARG BUILD_MODE=staging
|
||||
ARG NODE_ENV=staging
|
||||
# Define build arguments for test stage
|
||||
ARG BUILD_MODE=test
|
||||
ARG NODE_ENV=test
|
||||
|
||||
# Set environment variables
|
||||
ENV BUILD_MODE=${BUILD_MODE}
|
||||
ENV NODE_ENV=${NODE_ENV}
|
||||
|
||||
# Copy staging-specific nginx configuration
|
||||
# Copy test-specific nginx configuration
|
||||
COPY docker/staging.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Expose port 80
|
||||
|
||||
Reference in New Issue
Block a user