heyputer-puter
SUCCESS
105m 04s
History Source
SummaryIterations2Transcript22Dockerfile
Dockerfile49 lines · 1045 chars
# Multi-stage build for Puter

# Build stage: install dependencies and build GUI
FROM node:24-alpine AS build

# Install build tools
RUN apk add --no-cache git python3 make g++ \
    && ln -sf /usr/bin/python3 /usr/bin/python

# Working directory
WORKDIR /app

# Copy manifest and lockfile first for better caching
COPY package.json package-lock.json ./

# Fail-fast if manifest files are missing
RUN test -f package.json && test -f package-lock.json

# Copy the full source for build steps
COPY . .

# Install dependencies
RUN npm ci

# Build the GUI assets
RUN cd src/gui && npm run build && cd -

# Production stage: runtime image
FROM node:24-alpine

# Install minimal runtime dependencies
RUN apk add --no-cache curl

# Prepare runtime working directory
WORKDIR /app

# Bring over built artifacts and necessary files from the build stage
COPY --from=build /app /app

# Ensure proper ownership for the non-root user
RUN adduser -D appuser
USER appuser

# Expose the application port
EXPOSE 4100

# Start the application
CMD ["npm", "start"]