test(docker): more testing on how i want to build the docker part of the app
This commit is contained in:
48
Dockerfile
48
Dockerfile
@@ -1,29 +1,49 @@
|
|||||||
# Install dependencies
|
# Stage 1: Build the Express.js app
|
||||||
FROM node:24-alpine AS deps
|
FROM node:24-alpine AS app-builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
COPY app ./app
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
RUN npm run build:app
|
||||||
|
|
||||||
# Build app
|
#--------------------
|
||||||
FROM node:24-alpine AS builder
|
|
||||||
WORKDIR /app
|
# Stage 2: Build the Docusaurus docs
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
FROM node:24-alpine AS docs-builder
|
||||||
COPY . .
|
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
|
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
|
FROM node:24-alpine AS runner
|
||||||
WORKDIR /app
|
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 ./
|
COPY package*.json ./
|
||||||
RUN npm install --omit=dev --ignore-scripts
|
RUN npm install --omit=dev --ignore-scripts
|
||||||
|
|
||||||
# Copy compiled app
|
# Copy the built artifacts from each builder stage
|
||||||
COPY --from=builder /app/dist ./dist
|
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
|
EXPOSE 4200
|
||||||
ENV NODE_ENV=dev
|
|
||||||
ENV RUNNING_IN_DOCKER=true
|
|
||||||
|
|
||||||
CMD ["node", "dist/main.js"]
|
CMD ["node", "dist/main.js"]
|
||||||
@@ -14,6 +14,9 @@
|
|||||||
"build:docs": "cd lstDocs && rimraf build && npm run build",
|
"build:docs": "cd lstDocs && rimraf build && npm run build",
|
||||||
"build:wrapper": "cd lstWrapper && rimraf publish && dotnet publish -c Release -o ./publish",
|
"build:wrapper": "cd lstWrapper && rimraf publish && dotnet publish -c Release -o ./publish",
|
||||||
"build": "npm run build:docs && npm run build:front && npm run build:app",
|
"build": "npm run build:docs && npm run build:front && npm run build:app",
|
||||||
|
"install:front": "cd frontend && npm i",
|
||||||
|
"install:doc": "cd lstDocs && npm i",
|
||||||
|
"install:app": "npm i",
|
||||||
"start:app": "set NODE_ENV=production && node dist/main.js",
|
"start:app": "set NODE_ENV=production && node dist/main.js",
|
||||||
"start": "dotenvx run -f .env -- npm run start:app",
|
"start": "dotenvx run -f .env -- npm run start:app",
|
||||||
"docker": "docker build --no-cache -t lst-test .",
|
"docker": "docker build --no-cache -t lst-test .",
|
||||||
|
|||||||
Reference in New Issue
Block a user