mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-23 18:25:25 +00:00
Add blank lines before headers
This commit is contained in:
@@ -48,6 +48,7 @@ func main() {
|
||||
**多阶段 Dockerfile:**
|
||||
|
||||
```dockerfile
|
||||
|
||||
# Stage 1: 构建阶段
|
||||
FROM golang:1.20-alpine AS builder
|
||||
|
||||
@@ -91,6 +92,7 @@ ENTRYPOINT ["/app"]
|
||||
**构建和测试:**
|
||||
|
||||
```bash
|
||||
|
||||
# 构建镜像
|
||||
docker build -t go-app:latest .
|
||||
|
||||
@@ -105,6 +107,7 @@ curl http://localhost:8080/health | jq .
|
||||
|
||||
# 进入容器验证
|
||||
docker exec go-demo ls -la /
|
||||
|
||||
# 只包含 /app 和系统必要文件
|
||||
|
||||
# 镜像大小通常 < 10MB(相比 golang:1.20-alpine 的 ~1GB)
|
||||
@@ -246,6 +249,7 @@ serde_json = "1.0"
|
||||
**多阶段构建 Dockerfile:**
|
||||
|
||||
```dockerfile
|
||||
|
||||
# Stage 1: 编译
|
||||
FROM rust:1.75-alpine AS builder
|
||||
|
||||
@@ -490,6 +494,7 @@ HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
||||
|
||||
```ini
|
||||
[mysqld]
|
||||
|
||||
# 性能优化
|
||||
max_connections = 200
|
||||
default_storage_engine = InnoDB
|
||||
@@ -530,6 +535,7 @@ HEALTHCHECK --interval=5s --timeout=3s --retries=5 \
|
||||
**redis.conf 配置:**
|
||||
|
||||
```text
|
||||
|
||||
# 绑定地址
|
||||
bind 0.0.0.0
|
||||
|
||||
@@ -841,6 +847,7 @@ WORKDIR /workspace
|
||||
**Docker Compose 用于 Dev Containers:**
|
||||
|
||||
```yaml
|
||||
|
||||
# .devcontainer/docker-compose.yml
|
||||
version: '3.9'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user