Update docker file
This commit is contained in:
16
src/Managing.WebApp/.dockerignore
Normal file
16
src/Managing.WebApp/.dockerignore
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
node_modules
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.dockerignore
|
||||||
|
Dockerfile*
|
||||||
|
README.md
|
||||||
|
.env
|
||||||
|
.nyc_output
|
||||||
|
coverage
|
||||||
|
.DS_Store
|
||||||
|
*.log
|
||||||
|
dist
|
||||||
|
build
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Use an official Node.js image as the base
|
# Use an official Node.js image as the base (using standard instead of alpine for better compatibility)
|
||||||
FROM node:18-alpine
|
FROM node:18 AS builder
|
||||||
|
|
||||||
# Set the working directory in the container
|
# Set the working directory in the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -7,35 +7,40 @@ WORKDIR /app
|
|||||||
# Set environment variable to skip Chromium download
|
# Set environment variable to skip Chromium download
|
||||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||||
|
|
||||||
# Install git and Python
|
# Install git (needed for git dependencies)
|
||||||
#RUN apk update && apk add --no-cache git python3 make g++
|
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Create a symlink for python3 as python
|
|
||||||
#RUN ln -sf /usr/bin/python3 /usr/bin/python
|
|
||||||
|
|
||||||
# Copy package.json and package-lock.json to the container
|
# Copy package.json and package-lock.json to the container
|
||||||
# COPY package*.json ./
|
COPY src/Managing.WebApp/package*.json ./
|
||||||
COPY /src/Managing.WebApp/package.json ./
|
|
||||||
|
|
||||||
# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts
|
# Clean npm cache and install dependencies with verbose logging
|
||||||
RUN npm install --legacy-peer-deps
|
RUN npm cache clean --force
|
||||||
|
|
||||||
|
# Set npm timeout and try installing with increased verbosity and timeout
|
||||||
|
RUN npm config set fetch-timeout 300000
|
||||||
|
RUN npm config set fetch-retry-mintimeout 20000
|
||||||
|
RUN npm config set fetch-retry-maxtimeout 120000
|
||||||
|
|
||||||
|
# Install dependencies with error handling
|
||||||
|
RUN npm install --legacy-peer-deps --verbose --no-optional || \
|
||||||
|
(echo "First attempt failed, trying without cache..." && \
|
||||||
|
rm -rf node_modules package-lock.json && \
|
||||||
|
npm install --legacy-peer-deps --no-cache)
|
||||||
|
|
||||||
|
# Install global dependencies
|
||||||
RUN npm install -g tailwindcss postcss autoprefixer @tailwindcss/typography
|
RUN npm install -g tailwindcss postcss autoprefixer @tailwindcss/typography
|
||||||
|
|
||||||
# Copy the rest of the app's source code to the container
|
# Copy the rest of the app's source code to the container
|
||||||
# COPY . .
|
|
||||||
RUN ls -la
|
|
||||||
COPY src/Managing.WebApp/ .
|
COPY src/Managing.WebApp/ .
|
||||||
RUN node --max-old-space-size=8192 ./node_modules/.bin/vite build
|
|
||||||
|
|
||||||
# Build the app
|
# Build the app (vite build should be sufficient, no need for separate npm run build)
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Use NGINX as the web server
|
# Use NGINX as the web server
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
# Copy the built app to the NGINX web server directory
|
# Copy the built app to the NGINX web server directory
|
||||||
# COPY --from=0 /app/build /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
COPY --from=0 /app/dist /usr/share/nginx/html
|
|
||||||
|
|
||||||
# Expose port 80 for the NGINX web server
|
# Expose port 80 for the NGINX web server
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|||||||
Reference in New Issue
Block a user