Initial commit
This commit is contained in:
51
Dockerfile
Normal file
51
Dockerfile
Normal file
@@ -0,0 +1,51 @@
|
||||
# Multi-stage build Dockerfile for Svelte MUD client
|
||||
|
||||
# Build stage
|
||||
FROM node:20-alpine AS build
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy source files
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:20-alpine AS production
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Create a non-root user and group with the node user ID
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S -u 1001 -G nodejs nodejs
|
||||
|
||||
# Install only production dependencies
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Copy built application from the build stage
|
||||
COPY --from=build /app/build ./build
|
||||
COPY --from=build /app/src/websocket-server.js ./src/
|
||||
COPY production.js ./
|
||||
|
||||
# Switch to non-root user
|
||||
USER nodejs
|
||||
|
||||
# Expose ports for both web and websocket servers
|
||||
EXPOSE 3000
|
||||
EXPOSE 3001
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Start the full application (web + websocket)
|
||||
CMD ["node", "production.js"]
|
||||
Reference in New Issue
Block a user