Skip to content

Commit b0e99b6

Browse files
committed
Use an entrypoint to prepare the environment before Julia is launched.
Stuff can happen during init that depends on it.
1 parent 445e21e commit b0e99b6

File tree

4 files changed

+48
-29
lines changed

4 files changed

+48
-29
lines changed

runner.arch/Dockerfile runner/Dockerfile.arch

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ RUN mkdir /storage /cache && \
2020

2121
WORKDIR /home/pkgeval
2222
USER pkgeval
23+
24+
COPY ./entrypoint.sh /
25+
ENTRYPOINT ["/entrypoint.sh"]

runner.ubuntu/Dockerfile runner/Dockerfile.ubuntu

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ RUN mkdir /storage /cache && \
2222

2323
WORKDIR /home/pkgeval
2424
USER pkgeval
25+
26+
COPY ./entrypoint.sh /
27+
ENTRYPOINT ["/entrypoint.sh"]

runner/entrypoint.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash -ue
2+
3+
DEPOT=$1
4+
shift
5+
6+
mkdir $DEPOT
7+
8+
mkdir -p /storage/artifacts
9+
ln -s /storage/artifacts $DEPOT/artifacts
10+
11+
# allow identification of PkgEal
12+
export CI=true
13+
export PKGEVAL=true
14+
export JULIA_PKGEVAL=true
15+
16+
# disable system discovery of Python and R
17+
export PYTHON=""
18+
export R_HOME="*"
19+
20+
# no automatic precompilation
21+
export JULIA_PKG_PRECOMPILE_AUTO=0
22+
23+
exec "$@"

src/run.jl

+19-29
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export Configuration
22

33
function prepare_runner()
4-
for runner in ("ubuntu", "arch")
5-
cd(joinpath(dirname(@__DIR__), "runner.$runner")) do
6-
cmd = `docker build --tag newpkgeval:$runner .`
4+
cd(joinpath(dirname(@__DIR__), "runner")) do
5+
for runner in ("ubuntu", "arch")
6+
cmd = `docker build --tag newpkgeval:$runner --file Dockerfile.$runner .`
77
if !isdebug(:docker)
88
cmd = pipeline(cmd, stdout=devnull, stderr=devnull)
99
end
@@ -44,7 +44,9 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
4444
storage=nothing, cache=nothing, sysimage=nothing,
4545
runner="ubuntu", depot="/home/pkgeval/.julia",
4646
xvfb::Bool=true, init::Bool=true)
47-
cmd = `docker run`
47+
## Docker args
48+
49+
cmd = `docker run --rm`
4850

4951
# expose any available GPUs if they are available
5052
if find_library("libcuda") != ""
@@ -59,16 +61,9 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
5961
cmd = ```$cmd --mount type=bind,source=$julia_path,target=/opt/julia,readonly
6062
--mount type=bind,source=$registry_path,target=/usr/local/share/julia/registries,readonly
6163
--env JULIA_DEPOT_PATH="$depot:/usr/local/share/julia"
62-
--env JULIA_PKG_PRECOMPILE_AUTO=0
6364
--env JULIA_PKG_SERVER
6465
```
6566

66-
# allow identification of PkgEval
67-
cmd = `$cmd --env CI=true --env PKGEVAL=true --env JULIA_PKGEVAL=true`
68-
69-
# disable system discovery of Python and R
70-
cmd = `$cmd --env PYTHON="" --env R_HOME="*"`
71-
7267
if storage !== nothing
7368
cmd = `$cmd --mount type=bind,source=$storage,target=/storage`
7469
end
@@ -77,10 +72,6 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
7772
cmd = `$cmd --mount type=bind,source=$cache,target=/cache`
7873
end
7974

80-
if sysimage !== nothing
81-
args = `--sysimage=$sysimage $args`
82-
end
83-
8475
# mount working directory in tmpfs
8576
if tmpfs
8677
cmd = `$cmd --tmpfs /home/pkgeval:exec,uid=1000,gid=1000`
@@ -110,10 +101,19 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
110101
cmd = `$cmd --init`
111102
end
112103

104+
cmd = `$cmd newpkgeval:$runner`
105+
106+
107+
## Julia args
108+
109+
if sysimage !== nothing
110+
args = `--sysimage=$sysimage $args`
111+
end
112+
113113
if xvfb
114-
`$cmd --rm newpkgeval:$runner xvfb-run /opt/julia/bin/julia $args`
114+
`$cmd $depot xvfb-run /opt/julia/bin/julia $args`
115115
else
116-
`$cmd --rm newpkgeval:$runner /opt/julia/bin/julia $args`
116+
`$cmd $depot /opt/julia/bin/julia $args`
117117
end
118118
end
119119

@@ -146,12 +146,6 @@ function run_sandboxed_test(install::String, pkg; log_limit = 2^20 #= 1 MB =#,
146146
versioninfo()
147147
println()
148148
149-
mkpath(first(DEPOT_PATH))
150-
151-
# global storage of downloaded artifacts
152-
mkpath("/storage/artifacts")
153-
symlink("/storage/artifacts", joinpath(first(DEPOT_PATH), "artifacts"))
154-
155149
using Pkg
156150
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
157151
@@ -385,12 +379,6 @@ function run_compiled_test(install::String, pkg; compile_time_limit=30*60, cache
385379
versioninfo()
386380
println()
387381
388-
mkpath(first(DEPOT_PATH))
389-
390-
# global storage of downloaded artifacts
391-
mkpath("/storage/artifacts")
392-
symlink("/storage/artifacts", joinpath(first(DEPOT_PATH), "artifacts"))
393-
394382
using Pkg
395383
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
396384
@@ -504,6 +492,7 @@ function run(configs::Vector{Configuration}, pkgs::Vector;
504492
for (config, (install,cache)) in instantiated_configs
505493
Base.run(```docker run --mount type=bind,source=$storage,target=/storage
506494
--mount type=bind,source=$cache,target=/cache
495+
--entrypoint=''
507496
newpkgeval:ubuntu
508497
sudo chown -R pkgeval:pkgeval /storage /cache```)
509498
end
@@ -744,6 +733,7 @@ function run(configs::Vector{Configuration}, pkgs::Vector;
744733
uid = ccall(:getuid, Cint, ())
745734
gid = ccall(:getgid, Cint, ())
746735
Base.run(```docker run --mount type=bind,source=$cache,target=/cache
736+
--entrypoint=''
747737
newpkgeval:ubuntu
748738
sudo chown -R $uid:$gid /cache```)
749739
rm(cache; recursive=true)

0 commit comments

Comments
 (0)