|
| 1 | +# Freighter |
| 2 | +Freighter is a Rust private registry implementation designed to be, above all else, modular, fast and operationally |
| 3 | +boring. Freighter is intended to be something you can feel comfortable deploying and then ignoring until the end of |
| 4 | +time. |
| 5 | + |
| 6 | +## Features |
| 7 | + |
| 8 | +### Configurability |
| 9 | +Freighter is configurable via a yaml file parsed at startup. |
| 10 | + |
| 11 | +### Scalability |
| 12 | +Freighter stores the index in PostgreSQL databases, and crate tarballs in services implementing basic elements of the |
| 13 | +S3 API. |
| 14 | + |
| 15 | +### Observability |
| 16 | +Freighter exposes metrics via prometheus, and logs to stdout using `tracing`. |
| 17 | + |
| 18 | +### Graceful Restarts |
| 19 | +Freighter will stop accepting new requests but continue handling existing ones when a SIGTERM is received. |
| 20 | + |
| 21 | +## Running locally |
| 22 | + |
| 23 | +To try out Freighter **locally**, start a `postgres:14` or `postgres:15` server: |
| 24 | +``` |
| 25 | +docker run -it -e POSTGRES_USER=freighter -e POSTGRES_PASSWORD=crates-crates-crates -p 5432:5432 -v /data:/var/lib/postgresql/data postgres:14 |
| 26 | +``` |
| 27 | + |
| 28 | +Run the migrations, e.g. with a locally installed `psql`: |
| 29 | +``` |
| 30 | +PGPASSWORD=crates-crates-crates psql -U freighter -h localhost -f sql/init-index-db.sql |
| 31 | +PGPASSWORD=crates-crates-crates psql -U freighter -h localhost -f sql/init-auth-db.sql |
| 32 | +``` |
| 33 | + |
| 34 | +Next, we need an S3-compatible server. You can use an S3 emulator for testing purposes: |
| 35 | +``` |
| 36 | +docker run -it -p 9090:9090 -e initialBuckets=crates -e validKmsKeys="arn:aws:kms:us-east-1:1234567890:key/valid-secret" -e debug=true -t adobe/s3mock |
| 37 | +``` |
| 38 | + |
| 39 | +Finally, a config file using the above: |
| 40 | +```yaml |
| 41 | +service: |
| 42 | + address: "127.0.0.1:3000" |
| 43 | + download_endpoint: "127.0.0.1:3000/downloads/{crate}/{version}" |
| 44 | + api_endpoint: "127.0.0.1:3000" |
| 45 | + metrics_address: "127.0.0.1:3001" |
| 46 | + |
| 47 | +index_db: &db |
| 48 | + dbname: "freighter" |
| 49 | + user: "freighter" |
| 50 | + password: "crates-crates-crates" |
| 51 | + host: "localhost" |
| 52 | + port: 5432 |
| 53 | + |
| 54 | +auth_db: *db |
| 55 | + |
| 56 | +store: |
| 57 | + name: "crates" |
| 58 | + endpoint_url: "http://127.0.0.1:9090" |
| 59 | + region: "us-east-1" |
| 60 | + access_key_id: "1234567890" |
| 61 | + access_key_secret: "valid-secret" |
| 62 | +``` |
| 63 | +
|
| 64 | +Start Freighter: |
| 65 | +``` |
| 66 | +cargo run -p freighter -- -c config.yaml |
| 67 | +``` |
0 commit comments