(01)Build from Dockerfile
Linux
1docker build -t myapp:1.0 -f Dockerfile.python .2docker build -t myapi:local .3docker images | grep myappProduction-ready Dockerfile patterns for Python, Node.js, and multi-stage builds
Dockerfile.python
Flask / FastAPI Python API
1FROM python:3.12-slim2WORKDIR /app3COPY requirements.txt .4RUN pip install --no-cache-dir -r requirements.txt5COPY . .6EXPOSE 30007# Dev: CMD ["python", "main.py"]8# Prod: CMD ["gunicorn", "-b", "0.0.0.0:3000", "main:app"]Dockerfile.node
Node.js API with dependency caching
1FROM node:20-alpine AS builder2WORKDIR /app3COPY package*.json ./4RUN npm ci --only=production5 6FROM node:20-alpine7WORKDIR /app8COPY --from=builder /app/node_modules ./node_modules9COPY . .10EXPOSE 300011USER node12CMD ["node", "src/index.js"]Dockerfile.spring
Spring Boot JAR (multi-stage)
1FROM maven:3.9-eclipse-temurin-21 AS build2WORKDIR /app3COPY pom.xml .4COPY src ./src5RUN mvn package -DskipTests6 7FROM eclipse-temurin:21-jre-alpine8WORKDIR /app9COPY --from=build /app/target/*.jar app.jar10EXPOSE 808011ENTRYPOINT ["java", "-jar", "app.jar"]Step 01
1docker build -t myapp:1.0 -f Dockerfile.python .2docker build -t myapi:local .3docker images | grep myapp