diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 5ab40f893..ac664a4e5 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -33,10 +33,8 @@ - [Database maintenance](./crates-io/db-maintenance.md) - [docs.rs](./docs-rs/README.md) - [Adding dependencies to the build environment](./docs-rs/add-dependencies.md) - - [Developing without docker-compose](./docs-rs/no-docker-compose.md) - [Self-hosting a docs.rs instance](./docs-rs/self-hosting.md) - [Maintenance procedures](./docs-rs/maintenance.md) - - [Migrating from a local database to S3](./docs-rs/migrate-s3.md) - [Governance](./governance/README.md) - [Infrastructure](./infra/README.md) - [Other Installation Methods](./infra/other-installation-methods.md) diff --git a/src/docs-rs/migrate-s3.md b/src/docs-rs/migrate-s3.md deleted file mode 100644 index 7f65a5cac..000000000 --- a/src/docs-rs/migrate-s3.md +++ /dev/null @@ -1,32 +0,0 @@ -# Migrating from a local database to S3 - -If you're running your own instance of docs.rs for personal development, and you'd like to test out the S3 integration, there are a couple steps involved. It's mostly straightforward, but there's at least one major caveat that should be taken into account. - -## Requirements - -Since docs.rs uses a fixed bucket name to upload files, you'll need to set up an independent server that implements the Amazon S3 API. [Minio](https://min.io/) is an example of a server you can set up. Instructions for installing and configuring Minio (or any S3-compliant provider) are beyond the scope of this article. - -## Configuring your docs.rs instance - -Once you have your server and credentials set up, you need to tell the docs.rs server to use it. You'll need to add some extra environment variables to the environment file you use to configure docs.rs. It uses the `S3_ENDPOINT` variable to determine where to call, and the other variables to configure its access privileges. The available environment variables are documented in `rusoto`'s [`EnvironmentProvider`](https://docs.rs/rusoto_credential/0.40.0/rusoto_credential/struct.EnvironmentProvider.html). - -```text -AWS_ACCESS_KEY_ID= -AWS_SECRET_ACCESS_KEY= -S3_ENDPOINT= -``` - -## Migrating files out of the database - -Before you restart the process to load the new credentials, the files that are currently in the local database need to be migrated out to S3. Once docs.rs sees that it has AWS credentials in its environment, it will stop reading from the `files` table entirely. Therefore, to properly transition to using the new file storage, you need to run an extra command to upload them. It's helpful to lock the build queue while this is happening, so that no new files will sneak in while the migration happens. - -```sh -cratesfyi build lock -# edit the environment file with the above variables if you haven't already -cratesfyi database move-to-s3 # this will take a while, depending on the size of your database -sudo systemctl restart cratesfyi # or however you manage your docs.rs service -# verify that files are loading from S3/Minio/etc -cratesfyi build unlock -``` - -Once this is done, new crate builds will upload files directly to your file storage service rather than into the database. The `move-to-s3` command will remove rows from the `files` table in the database as it uploads them, so once you're done, you can compact the database to shrink its on-disk size. diff --git a/src/docs-rs/no-docker-compose.md b/src/docs-rs/no-docker-compose.md deleted file mode 100644 index 93ebf5645..000000000 --- a/src/docs-rs/no-docker-compose.md +++ /dev/null @@ -1,111 +0,0 @@ -# Developing locally without docker-compose - -These are instructions for developing docs.rs locally. For deploying in a production environment, see [Self-hosting a docs.rs instance](self-hosting.html). - -While the docker-compose allows for easier setup of the required dependencies and environment, here is a breakdown of how to use the service without an outer docker container. This is useful e.g. for quickly iterating during development. - -Note that this does not remove the docker dependency altogether, since docs.rs uses docker at runtime for sandboxing. This just allows you to run commands more quickly since you are building in debug mode instead of release and are also caching more of the build. - -## Requirements - -The commands and package names on this page will assume a Debian-like machine with `apt` installed, but most dependencies should be relatively easy to find on Linux. Do note however that this requires the host to be `x86_64-unknown-linux-gnu`. - -Docs.rs has a few basic requirements: - -* Rust -* Git -* CMake, GCC, G++, and `pkg-config` (to build dependencies for crates and docs.rs itself) -* OpenSSL, zlib, curl, and `libmagic` (to link against) -* PostgreSQL - -```console -# apt install build-essential git curl cmake gcc g++ pkg-config libmagic-dev libssl-dev zlib1g-dev postgresql -$ sudo -u postgres psql -c "CREATE USER cratesfyi WITH PASSWORD 'password';" -$ sudo -u postgres psql -c "CREATE DATABASE cratesfyi OWNER cratesfyi;" -``` - -## Building the site - -Be warned - this builds over 350 crates! Depending on your computer, this may -take upwards of 10 minutes. - -```console -$ git clone https://github.com/rust-lang/docs.rs && cd docs.rs -$ cargo build -``` - -## The "prefix" directory - -docs.rs stores several files in a "prefix" directory. This can be anywhere, but if you put it in the doc.rs repo, it should go under the ./ignored/ directory so that it is not seen by git or the docker daemon. - -```console -$ mkdir -p ignored/cratesfyi-prefix -$ cd ignored/cratesfyi-prefix -$ mkdir -vp documentations public_html sources -$ git clone https://github.com/rust-lang/crates.io-index && cd crates.io-index -$ git branch crates-index-diff_last-seen -``` - -(That last command is used to set up the `crates-index-diff` crate, so we can start monitoring new crate releases.) - -## Docker group - -docs.rs needs to run docker containers for sandboxing. Therefore, you need to be in the 'docker' group to build crates. If you are already in the docker group, you can skip this step (you can check with `groups`). - -```console -# usermod -a -G docker "$USER" -$ # now logout and back in to your shell -$ cd /path/to/docs.rs/ignored/cratesfyi-prefix -``` - -## Environment for the server - -To ensure that the docs.rs server is configured properly, we need to set a few environment variables. This is most easily done by making a shell script. - -```sh -$ cd .. -$ echo ' -export CRATESFYI_PREFIX=. -# or add an appropriate username/password as necessary -export CRATESFYI_DATABASE_URL=postgresql://cratesfyi:password@localhost -export CRATESFYI_GITHUB_USERNAME= -export CRATESFYI_GITHUB_ACCESSTOKEN= -export RUST_LOG=cratesfyi,rustwide=info -' > env.sh -``` - -This last command assumes you put the shell script in `./env.sh`, -but you can name it anything as long as it is in the current directory. - -```console -$ . ./env.sh -$ cargo run database migrate -$ cargo run database update-search-index -$ cargo run database update-release-activity -# This will take between 5 and 30 minutes on the first run, depending on your internet speed. -# It downloads the rustops/crates-build-env crates which is almost 1 GB. -# It does not currently display a progress bar, this is https://github.com/rust-lang/rustwide/issues/9 -# As a workaround, you can run `docker pull rustops/crates-build-env` in a separate terminal. -$ cargo run build crate rand 0.5.5 -``` - -## Building on platforms other than Linux - -This is not currently possible. We assume in several places that the rustup toolchain is x86_64-unknown-linux-gnu. As a result, the only way to build on Mac or Alpine is to use the docker-compose file. - -## Resetting the database - -Occasionally, if you make changes to the migrations in a PR, those migrations will be saved in the database but will not be in the code when you switch back to the master branch. In this case, there is no way to undo the migration without knowing exactly which version of the code made the change (`cargo migrate` will have no effect). Here is a convenient shell script to reset the database so you don't have to remember how to undo your changes. - -NOTE: DO NOT RUN THIS IN PRODUCTION. - -```sh -#!/bin/sh -set -euv - -. ./env.sh - -sudo -u postgres dropdb cratesfyi --if-exists -sudo -u postgres psql -c 'CREATE DATABASE cratesfyi OWNER cratesfyi;' -cargo run database migrate -```