Skip to content

Commit bebacbd

Browse files
committed
update Docker config
1 parent 59c2588 commit bebacbd

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

Dockerfile

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
# Builder
2-
FROM node:18-alpine as builder
3-
# Reference :: https://pnpm.io/docker
4-
ENV PNPM_HOME="/pnpm"
5-
ENV PATH="$PNPM_HOME:$PATH"
6-
RUN corepack enable
7-
WORKDIR /src
1+
FROM node:lts-alpine AS base
82

9-
# Cache dependencies first
3+
# Stage 1: Install dependencies
4+
FROM base AS deps
5+
WORKDIR /app
106
COPY package.json pnpm-lock.yaml ./
11-
RUN pnpm install
7+
RUN corepack enable pnpm && pnpm install --frozen-lockfile
128

13-
# Copy other files and build
14-
COPY . /src/
15-
RUN pnpm build
9+
# Stage 2: Build the application
10+
FROM base AS builder
11+
WORKDIR /app
12+
COPY --from=deps /app/node_modules ./node_modules
13+
COPY . .
14+
RUN corepack enable pnpm && pnpm run build
1615

17-
# App
18-
FROM nginxinc/nginx-unprivileged
19-
COPY --chown=nginx:nginx --from=builder /src/out /app
20-
COPY default.conf /etc/nginx/conf.d/default.conf
16+
# Stage 3: Production image
17+
FROM nginx:stable AS production
18+
WORKDIR /app
19+
COPY --from=builder /app/out /app
20+
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
21+
22+
EXPOSE 80

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '3.9'
21
services:
32
jsoncrack:
43
image: jsoncrack
@@ -7,4 +6,6 @@ services:
76
context: .
87
dockerfile: Dockerfile
98
ports:
10-
- "8888:8080"
9+
- "8888:8080"
10+
environment:
11+
- NODE_ENV=production
File renamed without changes.

0 commit comments

Comments
 (0)