Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a deploy to heroku button and instructions on running a mirror! #440

Merged
merged 6 commits into from
Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 82 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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.
56 changes: 56 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}