genything / Dockerfile
burtenshaw
adapt to docker
6a75637
raw
history blame
1.29 kB
# Use an official Node.js runtime as a parent image
# Using LTS (Long Term Support) version is generally recommended
FROM node:20-alpine AS base
# Set the working directory in the container
WORKDIR /app
# Install dependencies stage
FROM base AS deps
# Copy package.json and package-lock.json (or yarn.lock or pnpm-lock.yaml)
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci
# Build stage
FROM base AS builder
# Copy dependencies from the 'deps' stage
COPY --from=deps /app/node_modules ./node_modules
# Copy the rest of the application code
COPY . .
# Build the SvelteKit application
RUN npm run build
# Production stage
FROM base AS production
ENV NODE_ENV=production
# Copy built application output from the 'builder' stage
# The output directory is typically 'build' when using adapter-node
COPY --from=builder /app/build ./build
# Copy production dependencies from the 'deps' stage
COPY --from=deps /app/node_modules ./node_modules
# Copy package.json to run the server
COPY package.json .
# Expose the port the app runs on
# SvelteKit with adapter-node typically defaults to 3000, but can be overridden by PORT env var
EXPOSE 7860
# Set the command to run the application
# This starts the Node.js server built by adapter-node
CMD ["node", "build/index.js"]