Files
bakery-ia/frontend/Dockerfile.development

38 lines
935 B
Docker
Raw Normal View History

2025-08-03 19:36:17 +02:00
# frontend/Dockerfile.development - FIXED VERSION
2025-07-17 13:54:51 +02:00
FROM node:18-alpine
2025-08-03 19:23:20 +02:00
# Install curl for healthchecks
RUN apk add --no-cache curl
# Set working directory
2025-07-17 13:54:51 +02:00
WORKDIR /app
2025-08-03 19:36:17 +02:00
# Create non-root user for security but don't switch yet
RUN addgroup -g 1001 -S nodejs && \
adduser -S reactjs -u 1001 -G nodejs
2025-08-03 19:23:20 +02:00
# Copy package files first (better caching)
2025-07-17 13:54:51 +02:00
COPY package*.json ./
2025-08-03 19:36:17 +02:00
# Install all dependencies (including dev dependencies) as root
RUN npm ci --verbose && \
npm cache clean --force
2025-07-17 13:54:51 +02:00
2025-08-03 19:23:20 +02:00
# Copy source code
2025-07-17 13:54:51 +02:00
COPY . .
2025-08-03 19:36:17 +02:00
# Change ownership of all files to the non-root user
RUN chown -R reactjs:nodejs /app
# Now switch to non-root user
2025-08-03 19:23:20 +02:00
USER reactjs
# Expose port 3000 (Vite default)
2025-07-17 13:54:51 +02:00
EXPOSE 3000
2025-08-03 19:23:20 +02:00
# Add healthcheck
2025-08-03 19:36:17 +02:00
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
2025-08-03 19:23:20 +02:00
CMD curl -f http://localhost:3000/ || exit 1
# Start development server with host binding
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]