Files
pfm/PostFundManagement.ConsoleUI/Dockerfile
T

42 lines
1.1 KiB
Docker

# Stage 1: Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Enable corepack to use Yarn
RUN corepack enable
# Copy dependency definitions from the UI subdirectory into the container's /app folder
COPY PostFundManagement.ConsoleUI/package*.json PostFundManagement.ConsoleUI/yarn.lock* ./
# Install dependencies via Yarn
RUN yarn install --frozen-lockfile || yarn install
# Copy application source from the UI subdirectory into the container's /app folder
COPY PostFundManagement.ConsoleUI/ ./
# Build Vite application for production
RUN yarn build
# Stage 2: Production Nginx Server
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
# Copy nginx configuration from stage 1 build directory
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
# Copy compiled static assets from build stage
COPY --from=builder /app/dist ./
# Copy entrypoint script for dynamic runtime environment variables
COPY --from=builder /app/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# Expose port 3000
EXPOSE 3000
# Set entrypoint and default command
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]