This commit is contained in:
alirehmani
2024-05-10 17:01:34 +05:00
parent e74d1d33cd
commit 06b1b99126
6 changed files with 67 additions and 58 deletions

View File

@@ -3,5 +3,3 @@ node_modules
dist
dist-ssr
*.local
.env

View File

@@ -1,20 +1,41 @@
FROM node:18-alpine
# Use an official Node.js runtime as a parent image
FROM node:18
# Set the working directory inside the container
WORKDIR /app
COPY . /app
ENV NODE_ENV=production
# Install xsel for clipboard access (useful for some applications)
RUN apt-get update && apt-get install -y xsel
# Copy only package.json and package-lock.json (or yarn.lock) initially
# This takes advantage of cached Docker layers
COPY package*.json ./
# Install dependencies
# npm ci is used instead of npm install when you want a clean, exact installation
#RUN npm ci --verbose
# Try to install dependencies with a retry mechanism
#RUN for i in 1 2 3; do npm ci --verbose && break || sleep 15; done
RUN npm ci --production
# Copy the rest of your application code
COPY . .
# Set necessary environment variables (if they are not secrets)
ENV NODE_ENV=development
ENV VITE_API_URL_LOCAL=https://localhost:5001
ENV VITE_API_URL_SERVER=https://localhost
RUN npm install serve -g
RUN npm install
RUN npm run build
# Expose port 3000 for the application
EXPOSE 3000
# Install global dependencies if absolutely necessary (generally not recommended to do globally)
RUN npm install -g serve vite
# Build the application
RUN node --max-old-space-size=4096 node_modules/.bin/vite build
# Command to run the application
CMD ["npm", "run", "serve"]

View File

@@ -1,43 +0,0 @@
ARG NODE_VERSION=21.4.0
ARG ALPINE_VERSION=3.19.0
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
WORKDIR /app
# Copy the package.json and package-lock.json first to leverage Docker's cache
COPY ./src/Managing.WebApp/package*.json ./
# Install dependencies
RUN npm i --omit=dev
# Copy the application code
COPY . .
# Build the Vite application
RUN npm run build
# Stage 2: Create the runtime image
FROM nginx:alpine
# Copy the built Vite application from the builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy a custom Nginx configuration file (if you need one)
# COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 80
EXPOSE 80
# Start the Nginx server
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# Array of known potentially hanging packages
hanging_packages=("xmlhttprequest-ssl@latest" "engine.io-parser@latest")
# Timeout in seconds for each package installation attempt
install_with_timeout() {
package=$1
echo "Attempting to install $package with a timeout of $timeout_duration seconds."
# Start npm install in the background
npm install $package --verbose &> $package.log &
# Get PID of the npm process
pid=$!
# Wait for the npm process to finish or timeout
(sleep $timeout_duration && kill -0 $pid 2>/dev/null && kill -9 $pid && echo "Timeout reached for $package, process killed." && echo $package >> exclude.log) &
waiter_pid=$!
# Wait for the npm process to complete
wait $pid
# Kill the waiter process in case npm finished before the timeout
kill -0 $waiter_pid 2>/dev/null && kill -9 $waiter_pid
}
# Install potentially hanging packages first with a timeout
for package in "${hanging_packages[@]}"; do
install_with_timeout $package
done

View File

@@ -28,6 +28,7 @@
"connectkit": "^1.7.3",
"date-fns": "^2.30.0",
"jotai": "^1.6.7",
"latest-version": "^9.0.0",
"lightweight-charts": "git+https://github.com/ntf/lightweight-charts.git",
"moment": "^2.29.3",
"plotly.js": "^2.18.1",

View File

@@ -2,7 +2,7 @@ import { Suspense, lazy } from 'react'
import { Route, Routes } from 'react-router-dom'
import LayoutMain from '../../layouts'
import Desk from '../../pages/desk/Desk'
import DeskWidget from '../../pages/desk/deskWidget'
import Scenario from '../../pages/scenarioPage/scenario'
import Tools from '../../pages/toolsPage/tools'
import Workflows from '../../pages/workflow/workflows'
@@ -96,7 +96,7 @@ const MyRoutes = () => {
index
element={
<Suspense fallback={null}>
<Desk />
<DeskWidget />
</Suspense>
}
/>