test(docker): more testing on how i want to build the docker part of the app

This commit is contained in:
2025-08-30 09:14:19 -05:00
parent 5d5401b248
commit e75883e587
2 changed files with 37 additions and 14 deletions

View File

@@ -1,29 +1,49 @@
# Install dependencies
FROM node:24-alpine AS deps
# Stage 1: Build the Express.js app
FROM node:24-alpine AS app-builder
WORKDIR /app
COPY package*.json ./
COPY app ./app
RUN npm install
RUN npm run build:app
# Build app
FROM node:24-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
#--------------------
# 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
# Production image
#--------------------
# 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
WORKDIR /app
ENV NODE_ENV=production
ENV RUNNING_IN_DOCKER=true
# Install only prod deps
# Copy production dependencies for the main app
COPY package*.json ./
RUN npm install --omit=dev --ignore-scripts
# Copy compiled app
COPY --from=builder /app/dist ./dist
# 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
ENV NODE_ENV=dev
ENV RUNNING_IN_DOCKER=true
CMD ["node", "dist/main.js"]