Skip to content

Commit 8821917

Browse files
committed
chore: root on macos and user on linux
1 parent cf3d1d8 commit 8821917

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

caribic/src/start.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ use std::process::Command;
2626
use std::time::Duration;
2727
use std::u64;
2828

29-
/// Get environment variables for Docker Compose, including UID/GID on Unix systems
29+
/// Get environment variables for Docker Compose, including UID/GID
30+
/// - macOS: Uses 0:0 (root) for compatibility
31+
/// - Linux: Uses actual user UID/GID
3032
fn get_docker_env_vars() -> Vec<(&'static str, String)> {
3133
let (uid, gid) = get_user_ids();
3234
vec![

caribic/src/utils.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::{error::Error, process::Output};
2323
use tokio::io::AsyncWriteExt;
2424
use zip::read::ZipArchive;
2525

26-
#[cfg(unix)]
26+
#[cfg(target_os = "linux")]
2727
use nix::unistd::{Uid, Gid};
2828

2929
pub fn print_header() {
@@ -590,19 +590,28 @@ pub fn query_balance(project_root_path: &Path, address: &str) -> u64 {
590590
.sum()
591591
}
592592

593-
/// Get current user's UID and GID for Docker containers (Unix only)
594-
/// Returns (UID, GID) or default (1000, 1000) on non-Unix systems
593+
/// Get current user's UID and GID for Docker containers
594+
/// - macOS: Returns 0:0 (root) for compatibility
595+
/// - Linux: Returns actual user UID/GID
596+
/// - Windows: Returns default 1000:1000
595597
pub fn get_user_ids() -> (String, String) {
596-
#[cfg(unix)]
598+
#[cfg(target_os = "macos")]
599+
{
600+
// Use root permissions on macOS
601+
("0".to_string(), "0".to_string())
602+
}
603+
604+
#[cfg(target_os = "linux")]
597605
{
606+
// Use actual user UID/GID on Linux
598607
let uid = Uid::current().as_raw();
599608
let gid = Gid::current().as_raw();
600609
(uid.to_string(), gid.to_string())
601610
}
602611

603-
#[cfg(not(unix))]
612+
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
604613
{
605-
// Default UID/GID for non-Unix systems (Windows)
614+
// Default UID/GID for other systems (Windows, etc.)
606615
("1000".to_string(), "1000".to_string())
607616
}
608617
}

chains/cardano/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ services:
9797
- ./kupo-db:/db
9898

9999
postgres:
100-
image: postgres:14.10-alpine
100+
image: postgres:15
101101
user: "${UID:-1000}:${GID:-1000}"
102102
environment:
103103
- POSTGRES_LOGGING=true

0 commit comments

Comments
 (0)