From fc0412749f9637d08f69924775071f75b53975b6 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 6 Feb 2020 16:52:20 -0500 Subject: [PATCH 1/4] make psql instructions copy/paste-able this was really annoying me --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index f16143b9f..1566a0b24 100644 --- a/README.md +++ b/README.md @@ -156,9 +156,7 @@ If you want to explore or edit database manually, you can connect to the databas with the `psql` command. ```sh -# this will print the name of the container it starts -docker-compose run -d db -docker exec -it psql -U cratesfyi +docker exec -it "$(docker-compose run -d db && sleep 1)" psql -U cratesfyi ``` The database contains a blacklist of crates that should not be built. From 47daf62365ff0b1a4f99a5cca2611244f759d221 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 6 Feb 2020 16:53:06 -0500 Subject: [PATCH 2/4] use local docker image if environment variable is set --- src/docbuilder/rustwide_builder.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/docbuilder/rustwide_builder.rs b/src/docbuilder/rustwide_builder.rs index a22bb1a92..8a88ff6b3 100644 --- a/src/docbuilder/rustwide_builder.rs +++ b/src/docbuilder/rustwide_builder.rs @@ -68,6 +68,7 @@ pub struct RustwideBuilder { impl RustwideBuilder { pub fn init() -> Result { + use rustwide::cmd::SandboxImage; let env_workspace_path = ::std::env::var("CRATESFYI_RUSTWIDE_WORKSPACE"); let workspace_path = env_workspace_path .as_ref() @@ -76,9 +77,13 @@ impl RustwideBuilder { let is_docker = std::env::var("DOCS_RS_DOCKER") .map(|s| s == "true") .unwrap_or(false); - let workspace = WorkspaceBuilder::new(Path::new(workspace_path), USER_AGENT) - .running_inside_docker(is_docker) - .init()?; + let mut builder = WorkspaceBuilder::new(Path::new(workspace_path), USER_AGENT) + .running_inside_docker(is_docker); + if let Ok(custom_image) = std::env::var("DOCS_RS_LOCAL_IMAGE") { + builder = builder.sandbox_image(SandboxImage::local(&custom_image)?); + } + + let workspace = builder.init()?; workspace.purge_all_build_dirs()?; let toolchain_name = std::env::var("CRATESFYI_TOOLCHAIN") @@ -255,7 +260,8 @@ impl RustwideBuilder { path: &Path, ) -> Result { self.update_toolchain()?; - let metadata = CargoMetadata::load(&self.workspace, &self.toolchain, path)?; + let metadata = CargoMetadata::load(&self.workspace, &self.toolchain, path) + .map_err(|err| err.context(format!("failed to load local package {}", path.display())))?; let package = metadata.root(); self.build_package(doc_builder, &package.name, &package.version, Some(path)) } From aa5e0bff389b2729ac2627fabd1fcc895890e823 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 23 Feb 2020 12:18:48 -0500 Subject: [PATCH 3/4] document that the one-liner starts a new container --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1566a0b24..4e4dd094f 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,11 @@ If you want to explore or edit database manually, you can connect to the databas with the `psql` command. ```sh +# NOTE: this creates a new container that will keep running after you exit +# To remove the new container, run `docker-compose down`. docker exec -it "$(docker-compose run -d db && sleep 1)" psql -U cratesfyi +# You only need to start the container once, in the future you can attach to it like so: +docker exec -it "$(docker container ps | grep postgres | cut -d ' ' -f 1)" psql -U cratesfyi ``` The database contains a blacklist of crates that should not be built. From aa10507f4c9078ea5680ef732974be053108a63e Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 23 Feb 2020 12:34:36 -0500 Subject: [PATCH 4/4] make the env variable even longer --- src/docbuilder/rustwide_builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docbuilder/rustwide_builder.rs b/src/docbuilder/rustwide_builder.rs index 8a88ff6b3..4066cb405 100644 --- a/src/docbuilder/rustwide_builder.rs +++ b/src/docbuilder/rustwide_builder.rs @@ -79,7 +79,7 @@ impl RustwideBuilder { .unwrap_or(false); let mut builder = WorkspaceBuilder::new(Path::new(workspace_path), USER_AGENT) .running_inside_docker(is_docker); - if let Ok(custom_image) = std::env::var("DOCS_RS_LOCAL_IMAGE") { + if let Ok(custom_image) = std::env::var("DOCS_RS_LOCAL_DOCKER_IMAGE") { builder = builder.sandbox_image(SandboxImage::local(&custom_image)?); }