Skip to content

Commit 9302837

Browse files
committed
Tweak
1 parent 7577d1d commit 9302837

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

crates/prek/src/languages/docker.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::sync::{Arc, LazyLock};
1111
use anyhow::{Context, Result};
1212
use lazy_regex::regex;
1313
use prek_consts::env_vars::EnvVars;
14-
use tracing::{debug, trace, warn};
14+
use tracing::{trace, warn};
1515

1616
use crate::cli::reporter::{HookInstallReporter, HookRunReporter};
1717
use crate::hook::{Hook, InstallInfo, InstalledHook};
@@ -225,7 +225,7 @@ impl ContainerRuntimeInfo {
225225
match RuntimeKind::from_str(&val) {
226226
Ok(runtime) => {
227227
if runtime != RuntimeKind::Auto {
228-
debug!(
228+
trace!(
229229
"Container runtime overridden by {}={}",
230230
EnvVars::PREK_CONTAINER_RUNTIME,
231231
val
@@ -253,7 +253,7 @@ impl ContainerRuntimeInfo {
253253
return RuntimeKind::AppleContainer;
254254
}
255255

256-
debug!("No container runtime found on PATH, defaulting to docker");
256+
trace!("No container runtime found on PATH, defaulting to docker");
257257
RuntimeKind::Docker
258258
}
259259

@@ -400,22 +400,24 @@ impl Docker {
400400
// the same as current `uid:gid` on the host - see subuid / subgid.
401401
}
402402

403+
// https://docs.docker.com/reference/cli/docker/container/run/#volumes-from
404+
// The `Z` option tells Docker to label the content with a private
405+
// unshared label. Only the current container can use a private volume.
403406
let work_dir = CONTAINER_RUNTIME.map_to_host_path(work_dir);
404407
let z = if CONTAINER_RUNTIME.is_apple_container() {
405408
"" // Not currently supported
406409
} else {
407410
",Z"
408411
};
412+
let volume = format!("{}:/src:rw{z}", work_dir.display());
413+
409414
if !CONTAINER_RUNTIME.is_apple_container() {
410415
// Run an init inside the container that forwards signals and reaps processes
411416
command.arg("--init");
412417
}
413418
command
414-
// https://docs.docker.com/reference/cli/docker/container/run/#volumes-from
415-
// The `Z` option tells Docker to label the content with a private
416-
// unshared label. Only the current container can use a private volume.
417419
.arg("--volume")
418-
.arg(format!("{}:/src:rw{}", work_dir.display(), z))
420+
.arg(volume)
419421
.arg("--workdir")
420422
.arg("/src");
421423

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Prek supports the following environment variables:
221221
- `auto` (default, auto-detect available runtime)
222222
- `docker`
223223
- `podman`
224-
- `container`
224+
- `container` (Apple's Container runtime on macOS, see [container](https://github.com/apple/container))
225225

226226
Compatibility fallbacks:
227227

docs/diff.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Gems specified in hook gemspec files and `additional_dependencies` will be insta
7878

7979
### Docker & Docker Image
8080

81-
`prek` auto-detects the available container runtime on the system (Docker, Podman, or Container) and uses it to run container-based hooks. You can also explicitly specify the container runtime using the `PREK_CONTAINER_RUNTIME` environment variable.
81+
`prek` auto-detects the available container runtime on the system (Docker, Podman, or [Container](https://github.com/apple/container)) and uses it to run container-based hooks. You can also explicitly specify the container runtime using the [`PREK_CONTAINER_RUNTIME`](configuration.md#environment-variables) environment variable.
8282

8383
## Command line interface
8484

0 commit comments

Comments
 (0)