diff --git a/README.md b/README.md index 153aa7cc60e..522007bfb44 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Source code for the default registry for Cargo users. Can be found online at [crates-io]: https://crates.io -## Installation +## Development Setup * `git clone` this repository * `npm install` @@ -121,3 +121,84 @@ For more information on using ember-cli, visit For more information on using cargo, visit [doc.crates.io](http://doc.crates.io/). + +## Deploying a Mirror + +**DISCLAIMER: The process of setting up a mirror is a work-in-progress and is +likely to change. It is not currently recommended for mission-critical +production use. It also requires a version of cargo newer than 0.13.0-nightly +(f09ef68 2016-08-02); the version of cargo currently on rustc's beta channel +fulfils this requirement and will be shipped with rustc 1.12.0 scheduled to be +released on 2016-09-29.** + +### Current functionality: a read-only, download-API-only mirror + +This mirror will function as a read-only duplicate of crates.io's API. You will +be able to download crates using your index and your mirror, but the crate files +will still come from crates.io's S3 storage. + +Your mirror will not: + +- Allow users to sign up/sign in +- Allow crate publish +- Keep track of any statistics +- Display available crates in its UI + +### API server setup + +To deploy the API on Heroku, use this button: + +[![Deploy](https://www.herokucdn.com/deploy/button.svg)][deploy] + +[deploy]: https://heroku.com/deploy + +The only config variable you need to set is `GIT_REPO_URL`, which should be the +git URL of your crates index repository; see the next section for setup +instructions for that. + +### Index mirror setup + +You also need a mirror of the crates.io git index, and your index needs to point +to your API server. + +1. `git clone https://github.com/rust-lang/crates.io-index.git` +2. Edit the config.json file to point to your API server so it looks like: + + ```json + { + "dl": "https://[your heroku app name].herokuapp.com/api/v1/crates", + "api": "https://[your heroku app name].herokuapp.com/" + } + ``` + +3. Commit and push to wherever you will be hosting your index (ex: github, + gitlab, an internal git server) + +4. In order to keep your mirror index up to date, schedule a `git pull` of the + official index. How to do this depends on how you are hosting your index, + but could be done through `cron` or a scheduled CI job, for example. + +### Cargo setup + +**NOTE: The following configuration requires a cargo version newer than +0.13.0-nightly (f09ef68 2016-08-02). The version of cargo that comes with rust +1.12.0 fulfils this requirement; this version is currently on the beta channel +and is scheduled to be released on 2016-09-29.** + +In the project where you want to use your mirror, change your `.cargo/config` +to replace the crates.io source to point to your crates index: + +```toml +[source] + +[source.mirror] +registry = "https://[host and path to your git server]/crates.io-index" + +[source.crates-io] +replace-with = "mirror" +registry = 'https://doesnt-matter-but-must-be-present' +``` + +Once [rust-lang/cargo#3089](https://github.com/rust-lang/cargo/pull/3089) is +released, it won't be necessary to specify a registry URL for a source being +replaced. diff --git a/app.json b/app.json new file mode 100644 index 00000000000..932f5613614 --- /dev/null +++ b/app.json @@ -0,0 +1,56 @@ +{ + "name": "Crates.io Mirror", + "description": "A mirror of crates.io", + "repository": "https://github.com/rust-lang/crates.io", + "env": { + "GIT_REPO_URL": { + "description": "The git URL of your crates index repository.", + }, + "GH_CLIENT_ID": { + "value": "", + "required": false + }, + "GH_CLIENT_SECRET": { + "value": "", + "required": false + }, + "S3_BUCKET": "crates-io", + "S3_ACCESS_KEY": { + "value": "", + "required": false + }, + "S3_SECRET_KEY": { + "value": "", + "required": false + }, + "SESSION_KEY": { + "generator": "secret" + }, + "HEROKU": "1", + "MIRROR": "1", + "GIT_REPO_CHECKOUT": "./tmp/index-co" + }, + "formation": { + "web": { + "quantity": 1, + "size": "Free" + } + }, + "addons": [ + "heroku-postgresql:hobby-dev" + ], + "buildpacks": [ + { + "url": "https://github.com/rcaught/heroku-buildpack-cmake.git#e4e2c9e" + }, + { + "url": "https://github.com/alexcrichton/heroku-buildpack-rust.git#ca218b5" + }, + { + "url": "https://github.com/tonycoco/heroku-buildpack-ember-cli.git#e4aed2b" + }, + { + "url": "https://github.com/ryandotsmith/nginx-buildpack.git#005ca03" + } + ] +}