update Docker config

This commit is contained in:
AykutSarac 2024-10-31 17:59:48 +03:00
parent 59c2588709
commit bebacbd585
No known key found for this signature in database
3 changed files with 21 additions and 18 deletions

View File

@ -1,20 +1,22 @@
# Builder FROM node:lts-alpine AS base
FROM node:18-alpine as builder
# Reference :: https://pnpm.io/docker
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /src
# Cache dependencies first # Stage 1: Install dependencies
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
RUN pnpm install RUN corepack enable pnpm && pnpm install --frozen-lockfile
# Copy other files and build # Stage 2: Build the application
COPY . /src/ FROM base AS builder
RUN pnpm build WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN corepack enable pnpm && pnpm run build
# App # Stage 3: Production image
FROM nginxinc/nginx-unprivileged FROM nginx:stable AS production
COPY --chown=nginx:nginx --from=builder /src/out /app WORKDIR /app
COPY default.conf /etc/nginx/conf.d/default.conf COPY --from=builder /app/out /app
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80

View File

@ -1,4 +1,3 @@
version: '3.9'
services: services:
jsoncrack: jsoncrack:
image: jsoncrack image: jsoncrack
@ -8,3 +7,5 @@ services:
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "8888:8080" - "8888:8080"
environment:
- NODE_ENV=production