Update Dockerfile-web-ui-dev

This commit is contained in:
liaquatali000
2024-05-10 20:41:37 +05:00
committed by GitHub
parent 8bf9b4341e
commit ab03ba7458

View File

@@ -1,46 +1,50 @@
ARG NODE_VERSION=18.20.0 # Set base image for the builder stage
ARG ALPINE_VERSION=3.19.0 ARG NODE_VERSION=18.17.0
FROM --platform=linux/arm64/v8 node:${NODE_VERSION} AS builder
FROM node:${NODE_VERSION}-alpine AS node
FROM alpine:${ALPINE_VERSION} AS builder
COPY --from=node /usr/lib /usr/lib
COPY --from=node /usr/local/lib /usr/local/lib
COPY --from=node /usr/local/include /usr/local/include
COPY --from=node /usr/local/bin /usr/local/bin
RUN node -v
# Set the working directory in the container # Set the working directory in the container
WORKDIR /app WORKDIR /app
# Copy the package.json and package-lock.json first to leverage Docker's cache # Install xsel if needed (uncomment if required in your environment)
COPY ./src/Managing.WebApp/package*.json ./ # RUN apt-get update && apt-get install -y xsel
RUN npm config set registry http://registry.cnpmjs.org
# Install dependencies
#RUN npm ci --production --loglevel=verbose
#RUN npm i --omit=dev --loglevel=verbose
RUN npm i --max-old-space-size=12000 --loglevel=verbose # Install Yarn
RUN npm install -g yarn
# Copy the application code # Copy the package.json and possibly yarn.lock first to leverage Docker's cache
COPY package.json yarn.lock* ./
# Optionally, add a specific package ignoring engine check
RUN yarn add whatwg-fetch@3.6.2 --ignore-engines
# Install all project dependencies with Yarn
RUN yarn install --network-timeout 1000000 --verbose
# Clear Yarn cache to ensure no corrupted data interferes with installation
RUN yarn cache clean
# Copy the rest of your application code
COPY . . COPY . .
# Build the Vite application # Set necessary environment variables (if they are not secrets)
RUN npm run build ENV NODE_ENV=development
ENV VITE_API_URL_LOCAL=https://localhost:5001
ENV VITE_API_URL_SERVER=https://localhost
# Build the application with increased memory options for Node
RUN node --max-old-space-size=4096 ./node_modules/.bin/vite build
# Stage 2: Create the runtime image # Stage 2: Create the runtime image
FROM nginx:alpine FROM --platform=linux/arm64/v8 nginx:alpine
# Copy the built Vite application from the builder stage # Copy the built Vite application from the builder stage
COPY --from=builder /app/dist /usr/share/nginx/html COPY --from=builder /app/dist /usr/share/nginx/html
# Copy a custom Nginx configuration file (if you need one) # Copy a custom Nginx configuration file (if needed)
# COPY nginx.conf /etc/nginx/nginx.conf # COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 80 # Expose port 80 for the Nginx server
EXPOSE 80 EXPOSE 80
# Start the Nginx server # Command to start the Nginx server
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]