Loading...
Loading...
Compare original and translation side by side
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
FROM node:20-alpine
RUN addgroup -g 1001 app && adduser -u 1001 -G app -D app
USER app
COPY /app .
HEALTHCHECK \
CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["node", "server.js"]FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
FROM node:20-alpine
RUN addgroup -g 1001 app && adduser -u 1001 -G app -D app
USER app
COPY /app .
HEALTHCHECK \
CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["node", "server.js"]FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /app/server .
FROM gcr.io/distroless/static:nonroot
COPY /app/server /server
CMD ["/server"]FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /app/server .
FROM gcr.io/distroless/static:nonroot
COPY /app/server /server
CMD ["/server"]RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*COPY package*.json ./
RUN npm ci
COPY . .COPY package*.json ./
RUN npm ci
COPY . .RUN git clone git@github.com:org/repo.gitENVARGCOPYdocker history--mount=type=secretRUN git clone git@github.com:org/repo.gitENVARGCOPYdocker history--mount=type=secrettarget "app" {
platforms = ["linux/amd64", "linux/arm64"]
cache-from = ["type=gha"]
cache-to = ["type=gha,mode=max"]
}target "app" {
platforms = ["linux/amd64", "linux/arm64"]
cache-from = ["type=gha"]
cache-to = ["type=gha,mode=max"]
}| Anti-pattern | Fix |
|---|---|
| Pin version: |
No | |
| Use specific permissions: |
| Remove or use specific |
| Mount only needed paths |
| Bind to |
| Use |
| 反模式 | 修复方案 |
|---|---|
| 固定版本: |
未设置 | 使用 |
| 使用特定权限: |
compose中设置 | 移除该配置或使用特定的 |
| 仅挂载所需路径 |
| 绑定到 |
| 使用 |
docker run --rm --entrypoint php myimage -vdocker run --rm --add-host backend:127.0.0.1 nginx-image nginx -tcp .env.example .envdocker compose config.env.exampledocker run --rm --entrypoint php myimage -vdocker run --rm --add-host backend:127.0.0.1 nginx-image nginx -tdocker compose config.env.example.env.env.example.gitnode_modulesvendor.env**.pem*.key.gitnode_modulesvendor.env**.pem*.keydepends_oncondition: service_healthyhealthcheckstart_periodnetworksinternal: trueprofiles: [debug]--profile debugdepends_oncondition: service_healthystart_periodhealthchecknetworksinternal: trueprofiles: [debug]--profile debugreferences/ci-testing.mdreferences/ci-testing.md