Refactored console dockerfile
This commit is contained in:
@@ -3,34 +3,39 @@ FROM node:20-alpine AS builder
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy dependency definitions
|
# Enable corepack to use Yarn
|
||||||
COPY PostFundManagement.ConsoleUI/package*.json ./
|
RUN corepack enable
|
||||||
|
|
||||||
# Install dependencies
|
# Copy dependency definitions from the subdirectory
|
||||||
RUN npm ci || npm install
|
COPY PostFundManagement.ConsoleUI/package*.json PostFundManagement.ConsoleUI/yarn.lock* ./
|
||||||
|
|
||||||
# Copy application source
|
# Install dependencies via Yarn
|
||||||
COPY PostFundManagement.ConsoleUI/ .
|
RUN yarn install --frozen-lockfile || yarn install
|
||||||
|
|
||||||
|
# Copy application source from the subdirectory
|
||||||
|
COPY PostFundManagement.ConsoleUI/ ./
|
||||||
|
|
||||||
# Build Vite application for production
|
# Build Vite application for production
|
||||||
RUN npm run build
|
RUN yarn build
|
||||||
|
|
||||||
# Stage 2: Production Nginx Server
|
# Stage 2: Production Nginx Server
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
# Copy nginx configuration
|
WORKDIR /usr/share/nginx/html
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
|
# 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 compiled static assets from build stage
|
||||||
COPY --from=builder /app/PostFundManagement.ConsoleUI/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist ./
|
||||||
|
|
||||||
# Copy entrypoint script for dynamic runtime environment variables
|
# Copy entrypoint script for dynamic runtime environment variables
|
||||||
COPY docker-entrypoint.sh /app/PostFundManagement.ConsoleUI/docker-entrypoint.sh
|
COPY --from=builder /app/docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
RUN chmod +x /app/PostFundManagement.ConsoleUI/docker-entrypoint.sh
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
|
|
||||||
# Expose port 3000
|
# Expose port 3000
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Set entrypoint and default command
|
# Set entrypoint and default command
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
Reference in New Issue
Block a user