# Multi-stage Dockerfile for startbootstrap-simple-sidebar # Build stage: install dependencies and build the project FROM node:22.22.3-alpine3.23 AS build WORKDIR /app # Install dependencies COPY package.json package-lock.json ./ RUN npm install # Copy all source files COPY . . # Build the project (generates dist directory) RUN npm run build # Runtime stage: serve the built dist directory with a lightweight static server FROM node:22.22.3-alpine3.23 AS runtime WORKDIR /app # Copy built assets from the build stage COPY --from=build /app/dist ./dist # Install a minimal static server to serve the built site RUN npm install -g http-server # Expose the port used by the static server EXPOSE 3000 # Start the static server serving the dist directory CMD ["http-server", "dist", "-p", "3000"]
# Exclude unnecessary files from Docker build context node_modules dist .git .gitignore npm-debug.log* yarn-debug.log* yarn-error.log* .vscode .DS_Store .env .env.* coverage logs *.log
Smoke [PASS]: apk add --no-cache curl >/dev/null 2>&1; http-server dist -p 3000 & PID=$!; i=0; max=15; while [ $i -lt $max ]; do if curl -fsS http://localhost:3000/ >/dev/null 2>&1; then break; fi; i=$((i+1)); sleep 1; done; if [ $i -ge $max ]; then kill $PID; exit 1; fi; kill $PID; exit 0