Skip to content

Allow using custom docker image #593

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

Merged
merged 4 commits into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <the container name goes here> 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.
Expand Down
14 changes: 10 additions & 4 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub struct RustwideBuilder {

impl RustwideBuilder {
pub fn init() -> Result<Self> {
use rustwide::cmd::SandboxImage;
let env_workspace_path = ::std::env::var("CRATESFYI_RUSTWIDE_WORKSPACE");
let workspace_path = env_workspace_path
.as_ref()
Expand All @@ -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")
Expand Down Expand Up @@ -255,7 +260,8 @@ impl RustwideBuilder {
path: &Path,
) -> Result<bool> {
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))
}
Expand Down