Test your understanding of Dockerfile instructions and container configuration!
# Use Node.js slim image for smaller size
FROM node:18-slim
# Set working directory
WORKDIR /usr/src/app
# Copy package files for dependency caching
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy application code
COPY . .
# Set environment variables
ENV NODE_ENV=production \
PORT=3000
# Expose application port
EXPOSE 3000
# Start application
CMD ["node", "server.js"]
# Use Python slim image for smaller size
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Copy requirements for dependency caching
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=5000
# Expose application port
EXPOSE 5000
# Start application
CMD ["python", "app.py"]