Update Dockerfile

This commit is contained in:
2026-08-17 14:32:04 +00:00
parent f795ddd0b8
commit 3b16d507f8

View File

@@ -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 WORKDIR /app
# Set production environment # Safety valve for the 2 GB host: without a cap a runaway build can exhaust the
ENV NODE_ENV="production" # 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 . . COPY . .
# Build application
RUN npm run build RUN npm run build
# Remove development dependencies # ---- Runtime stage ----
RUN npm prune --omit=dev FROM nginx:alpine
# Remove Nginx's default "Welcome" page files completely
RUN rm -rf /usr/share/nginx/html/*
# Final stage for app image # Only the compiled assets reach the final image — no node_modules, no source
FROM nginx
# Copy built application
COPY --from=build /app/dist /usr/share/nginx/html 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 EXPOSE 80 3000
CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ]
CMD ["nginx", "-g", "daemon off;"]