{"id":21055827,"url":"https://github.com/startdusk/zero2prod","last_synced_at":"2026-04-17T05:32:38.253Z","repository":{"id":140762748,"uuid":"533804617","full_name":"startdusk/zero2prod","owner":"startdusk","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-05T09:19:44.000Z","size":172,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T13:55:28.523Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/startdusk.png","metadata":{"files":{"readme":"README.cn.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-07T14:33:40.000Z","updated_at":"2022-10-08T00:51:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"72cd48b1-2c79-4683-833e-3d40eb3162a6","html_url":"https://github.com/startdusk/zero2prod","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/startdusk/zero2prod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startdusk%2Fzero2prod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startdusk%2Fzero2prod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startdusk%2Fzero2prod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startdusk%2Fzero2prod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/startdusk","download_url":"https://codeload.github.com/startdusk/zero2prod/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startdusk%2Fzero2prod/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31916881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T16:47:27.363Z","updated_at":"2026-04-17T05:32:38.230Z","avatar_url":"https://github.com/startdusk.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[项目参考原地址](https://github.dev/LukeMathWalker/zero-to-production)\n---\n\n### 1.rust编译默认的编译器编译很慢是慢在链接期，使用其他链接器提升编译速度(看情况使用，如果本来编译就不慢的话就不需要使用了)\n```bash\n# 在项目根目录下 新建 .cargo/config.toml\n\n# On Windows\n# ```\n# cargo install -f cargo-binutils\n# rustup component add llvm-tools-preview\n# ```\n[target.x86_64-pc-windows-msvc]\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]\n[target.x86_64-pc-windows-gnu]\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]\n\n# On Linux:\n# - Ubuntu, `sudo apt-get install lld clang`\n# - Arch, `sudo pacman -S lld clang`\n[target.x86_64-unknown-linux-gnu]\nrustflags = [\"-C\", \"linker=clang\", \"-C\", \"link-arg=-fuse-ld=lld\"]\n\n# On MacOS, `brew install michaeleisel/zld/zld`\n[target.x86_64-apple-darwin]\nrustflags = [\"-C\", \"link-arg=-fuse-ld=/usr/local/bin/zld\"]\n[target.aarch64-apple-darwin]\nrustflags = [\"-C\", \"link-arg=-fuse-ld=/usr/local/bin/zld\"]\n\n```\n\n### 2.使用编译热更新工具 [cargo-watch](https://crates.io/crates/cargo-watch)\n```bash\n# 安装\ncargo install cargo-watch\n\n# 执行命令 重新运行\ncargo watch -x check\n\n# 或 热更新 先测试 在运行\ncargo watch -x check -x test -x run\n```\n\n\n### 3.安装 sqlx-cli 工具, [教程](https://zhuanlan.zhihu.com/p/377943210)\nsqlx 自带了一个命令行工具，方便我们进行常规 SQL 的操作，如添加表格、添加索引、增减表的列等。\n\n利用 cargo 安装 sqlx-cli 这个工具:\n```bash\n# supports all databases supported by SQLx\ncargo install sqlx-cli\n\n# only for postgres\ncargo install sqlx-cli --no-default-features --features postgres\n```\n\n使用:\n\n1.先声明数据库链接地址\n```bash\nexport DATABASE_URL=postgres://postgres:password@127.0.0.1:5432/newsletter\n```\n2.创建数据库迁移文件\n```bash\nsqlx migrate add \u003c迁移文件件名\u003e\n```\n然后会在项目根目录下生成一个migrations/\u003c时间戳-迁移文件名\u003e\n然后，在这个文件里面添加你要执行SQL语句\n如:\n```sql\nCREATE TABLE subscriptions(\n\tid uuid NOT NULL,\n\tPRIMARY KEY (id),\n\temail TEXT NOT NULL UNIQUE,\n\tname TEXT NOT NULL,\n\tsubscribed_at timestamptz NOT NULL\n);\n```\n\n3.执行数据库迁移命令\n```bash\nsqlx migrate run\n```\n\n### 4.Docker 打包Rust镜像使用rust:x.xx.x-alpine会更小，但交叉编译成linux 需要使用 [`rust-musl-builder`](https://github.com/emk/rust-musl-builder)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstartdusk%2Fzero2prod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstartdusk%2Fzero2prod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstartdusk%2Fzero2prod/lists"}