ci(docker): updated docker to correctly build and run

This commit is contained in:
2025-08-31 09:07:06 -05:00
parent e75883e587
commit f348e4e053
4 changed files with 55 additions and 51 deletions

View File

@@ -1,49 +1,38 @@
# Stage 1: Build the Express.js app
FROM node:24-alpine AS app-builder
FROM node:24-alpine AS deps
WORKDIR /app
COPY package*.json ./
COPY app ./app
RUN mkdir frontend
RUN mkdir lstDocs
COPY frontend/package*.json ./frontend
COPY lstDocs/package*.json ./lstDocs
RUN npm install
RUN npm run build:app
RUN npm run install:front
RUN npm run install:docs
#--------------------
# Stage 2: Build the Docusaurus docs
FROM node:24-alpine AS docs-builder
WORKDIR /app/lstDocs
COPY lstDocs/package*.json ./
COPY --from=app-builder /app/node_modules /app/node_modules
COPY lstDocs ./
RUN npm install
RUN npm run build
#--------------------
# Stage 3: Build the Vite frontend
FROM node:24-alpine AS front-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
COPY --from=app-builder /app/node_modules /app/node_modules
COPY frontend ./
RUN npm install
RUN npm run build
#--------------------
# Stage 4: Create the final production image
FROM node:24-alpine AS runner
# Build the Next.js app
FROM node:24-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/frontend/node_modules ./frontend/node_modules
COPY --from=deps /app/lstDocs/node_modules ./lstDocs/node_modules
COPY . ./
RUN npm run build:app
RUN npm run build:front
RUN npm run build:docs
# Final stage
FROM node:24-alpine
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/frontend/dist ./frontend/dist
COPY --from=builder /app/lstDocs/build ./lstDocs/build
ENV NODE_ENV=production
ENV RUNNING_IN_DOCKER=true
# Copy production dependencies for the main app
COPY package*.json ./
RUN npm install --omit=dev --ignore-scripts
# Copy the built artifacts from each builder stage
COPY --from=app-builder /app/dist ./dist
COPY --from=docs-builder /app/lstDocs/build ./lstDocs/build
COPY --from=front-builder /app/frontend/dist ./frontend/dist
EXPOSE 4200
CMD ["node", "dist/main.js"]