More attempts to fix docker
This commit is contained in:
47
docker/app.Dockerfile
Normal file
47
docker/app.Dockerfile
Normal file
@@ -0,0 +1,47 @@
|
||||
# Multi-stage build Dockerfile for Svelte MUD web application
|
||||
|
||||
# Build stage
|
||||
FROM node:20-alpine AS build
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# 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 install --omit=dev
|
||||
|
||||
# Copy built application from the build stage
|
||||
COPY --from=build /app/build ./build
|
||||
COPY --from=build /app/docker-production.js ./
|
||||
|
||||
# Switch to non-root user
|
||||
USER nodejs
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
|
||||
# Start the SvelteKit production server
|
||||
CMD ["node", "docker-production.js"]
|
||||
29
docker/ws.Dockerfile
Normal file
29
docker/ws.Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
# Dockerfile for WebSocket server only
|
||||
|
||||
FROM node:20-alpine
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install only production dependencies
|
||||
RUN npm install --omit=dev
|
||||
|
||||
# Copy only the websocket server code
|
||||
COPY src/websocket-server.js ./src/
|
||||
|
||||
# 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
|
||||
|
||||
# Switch to non-root user
|
||||
USER nodejs
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV WS_PORT=3001
|
||||
|
||||
# Start the WebSocket server
|
||||
CMD ["node", "src/websocket-server.js"]
|
||||
Reference in New Issue
Block a user