Files
BattleBot/Dockerfile
2025-01-04 11:45:46 -06:00

35 lines
769 B
Docker

# Use an official Node runtime as the parent image
FROM node:18-slim
# Create app directory
WORKDIR /usr/src/app
# 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" ]