Update Dockerfile to copy built assets to nginx and use custom config
This commit is contained in:
parent
785b2049b9
commit
7ff308751e
1 changed files with 8 additions and 9 deletions
17
Dockerfile
17
Dockerfile
|
|
@ -3,13 +3,15 @@
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
FROM node:18-alpine AS builder
|
FROM node:18-alpine AS builder
|
||||||
|
|
||||||
# Install git (needed by some npm postinstall scripts)
|
# Install dependencies
|
||||||
RUN apk add --no-cache git
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies (uses package-lock if present, otherwise npm install)
|
# Copy package files
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Copy source files
|
# Copy source files
|
||||||
|
|
@ -20,15 +22,12 @@ ENV NODE_ENV=production
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# Production stage – tiny static server
|
# Production stage – tiny static server
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
# Remove default nginx config
|
# Copy only our custom config
|
||||||
RUN rm /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# Copy custom config
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d
|
|
||||||
|
|
||||||
# Copy built assets
|
# Copy built assets
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue