42
42
function runner_sandboxed_julia (install:: String , args= ` ` ; interactive= true , tty= true ,
43
43
name= nothing , cpus:: Vector{Int} = Int[], tmpfs:: Bool = true ,
44
44
storage= nothing , cache= nothing , sysimage= nothing ,
45
- depot= " /home/pkgeval/.julia" , install_dir= " /opt/julia" ,
46
45
xvfb:: Bool = true , init:: Bool = true ,
47
- runner= " ubuntu" )
46
+ runner= " ubuntu" , user= " pkgeval" , group= " pkgeval" ,
47
+ install_dir= " /opt/julia" )
48
48
# # Docker args
49
49
50
50
cmd = ` docker run --rm`
@@ -61,7 +61,7 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
61
61
@assert isdir (registry_path)
62
62
cmd = ``` $cmd --mount type=bind,source=$julia_path ,target=$install_dir ,readonly
63
63
--mount type=bind,source=$registry_path ,target=/usr/local/share/julia/registries,readonly
64
- --env JULIA_DEPOT_PATH="$depot :/usr/local/share/julia"
64
+ --env JULIA_DEPOT_PATH=": :/usr/local/share/julia"
65
65
--env JULIA_PKG_SERVER
66
66
```
67
67
@@ -75,10 +75,7 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
75
75
76
76
# mount working directory in tmpfs
77
77
if tmpfs
78
- cmd = ` $cmd --tmpfs /home/pkgeval:exec,uid=1000,gid=1000`
79
- # FIXME : tmpfs mounts don't copy uid/gid back, so we need to correct this manually
80
- # https://github.com/opencontainers/runc/issues/1647
81
- # FIXME : this also breaks mounting artifacts in the depot directly
78
+ cmd = ` $cmd --tmpfs /home/$user :exec`
82
79
end
83
80
84
81
# restrict resource usage
@@ -105,16 +102,32 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
105
102
cmd = ` $cmd newpkgeval:$runner `
106
103
107
104
105
+ # # Entrypoint script args
106
+
107
+ # use the current user and group ID to ensure cache and storage are writable
108
+ uid = ccall (:getuid , Cint, ())
109
+ gid = ccall (:getgid , Cint, ())
110
+ if uid < 1000 || gid < 1000
111
+ # system ids might conflict with groups/users in the container
112
+ @warn " You are running PkgEval as a system user (with id $uid :$gid ); this is not compatible with the container set-up.
113
+ I will be using id 1000:1000, but that means the cache and storage on the host file system will not be owned by you."
114
+ uid = 1000
115
+ gid = 1000
116
+ end
117
+
118
+ cmd = ` $cmd $user $uid $group $gid `
119
+
120
+
108
121
# # Julia args
109
122
110
123
if sysimage != = nothing
111
124
args = ` --sysimage=$sysimage $args `
112
125
end
113
126
114
127
if xvfb
115
- ` $cmd $depot xvfb-run $install_dir /bin/julia $args `
128
+ ` $cmd xvfb-run $install_dir /bin/julia $args `
116
129
else
117
- ` $cmd $depot $ install_dir /bin/julia $args `
130
+ ` $cmd $install_dir /bin/julia $args `
118
131
end
119
132
end
120
133
@@ -443,7 +456,7 @@ function run_compiled_test(install::String, pkg; compile_time_limit=30*60, cache
443
456
# in another path, etc)
444
457
return run_sandboxed_test (install, pkg; runner= " arch" ,
445
458
cache= cache, sysimage= sysimage_path,
446
- depot = " /home/pkgeval/.another_julia " ,
459
+ user = " user " , group = " group " ,
447
460
install_dir= " /usr/local/julia" , kwargs... )
448
461
end
449
462
@@ -495,15 +508,6 @@ function run(configs::Vector{Configuration}, pkgs::Vector;
495
508
storage = storage_dir ()
496
509
mkpath (storage)
497
510
498
- # make sure data is writable
499
- for (config, (install,cache)) in instantiated_configs
500
- Base. run (``` docker run --mount type=bind,source=$storage ,target=/storage
501
- --mount type=bind,source=$cache ,target=/cache
502
- --entrypoint=''
503
- newpkgeval:ubuntu
504
- sudo chown -R pkgeval:pkgeval /storage /cache``` )
505
- end
506
-
507
511
# ensure we can use Docker's API
508
512
info = let
509
513
docker = connect (" /var/run/docker.sock" )
@@ -737,12 +741,6 @@ function run(configs::Vector{Configuration}, pkgs::Vector;
737
741
# clean-up
738
742
for (config, (install,cache)) in instantiated_configs
739
743
rm (install; recursive= true )
740
- uid = ccall (:getuid , Cint, ())
741
- gid = ccall (:getgid , Cint, ())
742
- Base. run (``` docker run --mount type=bind,source=$cache ,target=/cache
743
- --entrypoint=''
744
- newpkgeval:ubuntu
745
- sudo chown -R $uid :$gid /cache``` )
746
744
rm (cache; recursive= true )
747
745
end
748
746
end
0 commit comments