chore: update content and add generated PDF

This commit is contained in:
Baohua Yang
2026-03-27 08:43:47 -07:00
parent 60df65e65b
commit f2f6858745
10 changed files with 24 additions and 24 deletions

View File

@@ -305,7 +305,7 @@ journalctl -u docker -n 100 | grep -i "oom"
```python
# Dockerfile
FROM python:3.11-slim
FROM python:3.14-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt memory_profiler tracemalloc
@@ -424,7 +424,7 @@ chmod +x hadolint
```dockerfile
# Stage 1: 构建阶段
FROM golang:1.20-alpine AS builder
FROM golang:1.26-alpine AS builder
WORKDIR /build
@@ -453,13 +453,13 @@ COPY --from=builder /build/app /app
EXPOSE 8080
ENTRYPOINT ["/app"]
# 最终镜像大小通常 < 15MB相比 golang:1.20-alpine 的 ~1GB
# 最终镜像大小通常 < 15MB相比 golang:1.26-alpine 的 ~1GB
```
**Node.js 应用的多阶段构建**
```dockerfile
# Stage 1: 依赖安装
FROM node:18-alpine AS dependencies
FROM node:24-alpine AS dependencies
WORKDIR /app
COPY package*.json ./
@@ -467,7 +467,7 @@ RUN npm ci --only=production && \
npm cache clean --force
# Stage 2: 构建阶段
FROM node:18-alpine AS builder
FROM node:24-alpine AS builder
WORKDIR /app
COPY package*.json ./
@@ -477,7 +477,7 @@ COPY . .
RUN npm run build
# Stage 3: 运行阶段
FROM node:18-alpine
FROM node:24-alpine
WORKDIR /app
@@ -504,7 +504,7 @@ CMD ["node", "dist/index.js"]
```dockerfile
# Stage 1: 构建阶段
FROM python:3.11-slim AS builder
FROM python:3.14-slim AS builder
WORKDIR /build
@@ -516,7 +516,7 @@ COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
# Stage 2: 运行阶段
FROM python:3.11-slim
FROM python:3.14-slim
WORKDIR /app
@@ -550,7 +550,7 @@ CMD ["python", "app.py"]
□ 使用 BuildKit 缓存优化加速构建
# 优化示例:
FROM ubuntu:22.04
FROM ubuntu:24.04
# ❌ 不推荐
RUN apt-get update