跳到主要内容
知仓学习社ZHICANG

rust-deployable-service

Use when preparing, containerizing, configuring, testing, or reviewing Rust services for deployment, especially Docker multi-stage builds, runtime c…

写文件严重 0 · 高危 1hashgraph-online/awesome-codex-plugins

它会碰到什么

扫了多少5 个文本文件,7 KB
它会碰到什么写文件
命中总数1 处
命中统计严重 0 · 高 1 · 中 0 · 低 0
逐条看命中(1 条严重或高危)
  • references/docker-rust.md:18fs-destructive
    && rm -rf /var/lib/apt/lists/*

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Rust Deployable Service

Use this skill when a Rust service needs to move from local development to a

repeatable container or cloud deployment. Keep runtime configuration explicit,

builds reproducible, and health checks boring.

Core Workflow

  1. Inspect Cargo.toml, workspace layout, Dockerfile, .dockerignore,

config files, migrations, .sqlx/, CI, and deployment docs.

  1. Identify the binary entrypoint and runtime dependencies: database, Redis,

external APIs, TLS roots, static files, templates, migrations, and config.

  1. Separate build-time and runtime configuration. Never bake production secrets

into images.

  1. Use hierarchical config with environment overrides for deployment-specific

values.

  1. Use a multi-stage Docker build and copy only the runtime binary and needed

assets into the final image.

  1. Account for SQLx query checking. Use SQLX_OFFLINE=true with checked-in

.sqlx/ metadata or provide a build-time database intentionally.

  1. Add health and readiness checks that match real dependencies.
  2. Run the bundled Docker preflight or the repository's equivalent CI command.

Configuration Rules

Read references/configuration.md when adding config files, environment

variables, or secret handling.

  • Keep local defaults convenient and production defaults conservative.
  • Validate config at startup before binding the server when possible.
  • Store secrets in environment variables or the deployment secret manager.
  • Avoid reading environment variables deep inside handlers or repositories.

Docker Rules

Read references/docker-rust.md before changing Docker builds.

  • Use dependency caching deliberately; avoid invalidating the whole build on

every source edit when practical.

  • Use --locked for release builds if the repo commits Cargo.lock.
  • Include CA certificates when outbound HTTPS is required.
  • Copy migrations, templates, and static assets only if the binary needs them at

runtime.

  • Run as a non-root user when the deployment platform supports it.

Verification

Run from the Rust project root when Docker is part of the delivery path:

path/to/rust-deployable-service/scripts/docker-preflight.sh

The script builds an image. It only runs a smoke command when

RUST_DEPLOY_SMOKE_COMMAND is set, because services often need environment and

infrastructure to start successfully.

Reference Files

  • references/configuration.md: typed config loading, overrides, validation,

and secrets.

  • references/docker-rust.md: multi-stage builds, SQLx offline builds, runtime

assets, and image checks.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。