# =============================================================================
# GoHorse Jobs Seeder API - Production Dockerfile
# =============================================================================

FROM node:20-alpine

WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm ci --only=production && npm cache clean --force

# Copy source
COPY src/ ./src/

# Security: Run as non-root
RUN addgroup -g 1001 -S nodejs && \
    adduser -u 1001 -S seeder -G nodejs && \
    chown -R seeder:nodejs /app

USER seeder

# Environment
ENV NODE_ENV=production \
    PORT=3001

EXPOSE 3001

# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
    CMD wget -qO- http://localhost:3001/health || exit 1

CMD ["node", "src/index.js"]
