From 3b16d507f8ac0fae1db973ceeba52ce8e22ec36c Mon Sep 17 00:00:00 2001 From: Suriya Date: Mon, 17 Aug 2026 14:32:04 +0000 Subject: [PATCH] Update Dockerfile --- Dockerfile | 51 +++++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7a89d4c..e822330 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,45 +1,32 @@ -# syntax = docker/dockerfile:1 +# ---- Build stage ---- +FROM node:22-alpine AS build -# Adjust NODE_VERSION as desired -ARG NODE_VERSION=22.13.1 -FROM node:${NODE_VERSION}-slim AS base - -LABEL fly_launch_runtime="Vite" - -# Vite app lives here WORKDIR /app -# Set production environment -ENV NODE_ENV="production" +# Safety valve for the 2 GB host: without a cap a runaway build can exhaust the +# server's RAM and take down neighbouring containers. Measured peak for this app +# is ~550 MB, so 1 GB leaves headroom while still failing the build rather than +# the server. Raise this only if the host gets more RAM. +ENV NODE_OPTIONS=--max-old-space-size=1024 +# Install deps from the lockfile first so this layer is reused when only src changes +COPY package.json package-lock.json ./ +RUN npm ci --no-audit --no-fund -# Throw-away build stage to reduce size of final image -FROM base AS build - -# Install packages needed to build node modules -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 - -# Install node modules -COPY package-lock.json package.json ./ -RUN npm ci --include=dev - -# Copy application code COPY . . - -# Build application RUN npm run build -# Remove development dependencies -RUN npm prune --omit=dev +# ---- Runtime stage ---- +FROM nginx:alpine +# Remove Nginx's default "Welcome" page files completely +RUN rm -rf /usr/share/nginx/html/* -# Final stage for app image -FROM nginx - -# Copy built application +# Only the compiled assets reach the final image — no node_modules, no source COPY --from=build /app/dist /usr/share/nginx/html -# Start the server by default, this can be overwritten at runtime +COPY nginx.conf /etc/nginx/nginx.conf + EXPOSE 80 3000 -CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ] + +CMD ["nginx", "-g", "daemon off;"]