fix(deploy): copy package.json into subdirs and run npm with --prefix to handle monorepo-like layout
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY backend/package*.json ./
|
||||
# Use npm ci if a lockfile exists, otherwise fall back to npm install
|
||||
RUN sh -c 'if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then npm ci --production; else npm install --production; fi'
|
||||
COPY backend/ ./
|
||||
COPY backend/package*.json backend/
|
||||
# Use npm ci if a lockfile exists in backend, otherwise fall back to npm install
|
||||
RUN sh -c 'if [ -f backend/package-lock.json ] || [ -f backend/npm-shrinkwrap.json ]; then npm ci --prefix backend --production; else npm install --prefix backend --production; fi'
|
||||
COPY backend/ backend/
|
||||
RUN npm run build --prefix backend
|
||||
|
||||
FROM node:20-alpine
|
||||
|
@@ -1,9 +1,9 @@
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY frontend/package*.json ./
|
||||
# Use npm ci when lockfile exists, fallback to npm install
|
||||
RUN sh -c 'if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then npm ci; else npm install; fi'
|
||||
COPY frontend/ ./
|
||||
COPY frontend/package*.json frontend/
|
||||
# Use npm ci when lockfile exists in frontend, fallback to npm install
|
||||
RUN sh -c 'if [ -f frontend/package-lock.json ] || [ -f frontend/npm-shrinkwrap.json ]; then npm ci --prefix frontend; else npm install --prefix frontend; fi'
|
||||
COPY frontend/ frontend/
|
||||
RUN npm run build --prefix frontend
|
||||
|
||||
FROM nginx:stable-alpine
|
||||
|
Reference in New Issue
Block a user