Files
BattleBot/Dockerfile
2025-01-04 11:53:48 -06:00

38 lines
878 B
Docker

# Use an official Node runtime as the parent image
FROM node:18-slim
# Create app directory
WORKDIR /usr/src/app
# Install curl for healthcheck
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Bundle app source
COPY . .
# Create a non-root user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 --ingroup nodejs nodejs && \
chown -R nodejs:nodejs /usr/src/app
USER nodejs
# Your app binds to port 3000
EXPOSE 3000
# Add healthcheck
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:3000/health || exit 1
# Define environment variable
ENV NODE_ENV=production
# Start the app
CMD [ "node", "index.js" ]