- Alpine Linux doesn't include curl by default - Use wget with --spider flag for health checks - Add wget installation to all Dockerfiles - This should resolve container health check failures
33 lines
640 B
Docker
33 lines
640 B
Docker
# Server Dockerfile - Colyseus Server
|
|
FROM node:20-alpine
|
|
|
|
# Install git and wget for npm dependencies and health checks
|
|
RUN apk add --no-cache git wget
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install all dependencies (including dev for build)
|
|
RUN npm install
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build TypeScript
|
|
RUN npm run build
|
|
|
|
# Remove dev dependencies after build
|
|
RUN npm prune --omit=dev
|
|
|
|
# Expose port
|
|
EXPOSE 2567
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:2567/health || exit 1
|
|
|
|
# Start server
|
|
CMD ["npm", "start"] |