Add Docker CI/CD
This commit is contained in:
16
Dockerfile
16
Dockerfile
@@ -1,20 +1,24 @@
|
||||
# Stage 1: Build application
|
||||
FROM node:22-bookworm-slim AS builder
|
||||
|
||||
# Stage 1: Install dependencies (including build tools)
|
||||
FROM node:22-bookworm-slim AS deps
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
RUN npm ci
|
||||
|
||||
# Stage 2: Build application
|
||||
FROM node:22-bookworm-slim AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Prepare static web server
|
||||
# Stage 3: Prepare static web server
|
||||
FROM alpine:3.19 AS server-prep
|
||||
RUN wget -O /tmp/sws.tar.gz \
|
||||
https://github.com/static-web-server/static-web-server/releases/download/v2.17.0/static-web-server-v2.17.0-x86_64-unknown-linux-musl.tar.gz
|
||||
RUN tar -xzf /tmp/sws.tar.gz -C /tmp \
|
||||
--strip-components=1
|
||||
|
||||
# Stage 3: Create runtime image
|
||||
# Stage 4: Create runtime image
|
||||
FROM gcr.io/distroless/static-debian12:nonroot
|
||||
|
||||
COPY --from=builder --chown=nonroot:nonroot /app/dist /app
|
||||
|
||||
Reference in New Issue
Block a user