Dockerfile.data-integration•1.15 kB
# BMTC MCP Data Integration Service Dockerfile
# Optimized multi-stage build for the data integration service
# Build stage
FROM node:16-alpine AS build
WORKDIR /app
# Copy only package files first to leverage Docker caching
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy the rest of the application
COPY . .
# Production stage
FROM node:16-alpine AS production
WORKDIR /app
# Create a non-root user to run the application
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 -G nodejs
# Copy node modules and app files from build stage
COPY --from=build --chown=nodejs:nodejs /app/node_modules /app/node_modules
COPY --from=build --chown=nodejs:nodejs /app/src /app/src
COPY --from=build --chown=nodejs:nodejs /app/package*.json /app/
# Create necessary directories with proper permissions
RUN mkdir -p /app/data/raw /app/data/processed /app/data/gtfs /app/logs && \
chown -R nodejs:nodejs /app/data /app/logs
# Set environment variables
ENV NODE_ENV=production
# Switch to non-root user
USER nodejs
# Command to run the application
CMD ["node", "src/data-integration-cli.js", "start"]