Skip to content

Commit

Permalink
Use an entrypoint to prepare the environment before Julia is launched.
Browse files Browse the repository at this point in the history
Stuff can happen during init that depends on it.
  • Loading branch information
maleadt committed Dec 3, 2020
1 parent 74b3b68 commit 1055cff
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 29 deletions.
3 changes: 3 additions & 0 deletions runner.arch/Dockerfile → runner/Dockerfile.arch
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ RUN mkdir /storage /cache && \

WORKDIR /home/pkgeval
USER pkgeval

COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
3 changes: 3 additions & 0 deletions runner.ubuntu/Dockerfile → runner/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ RUN mkdir /storage /cache && \

WORKDIR /home/pkgeval
USER pkgeval

COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
23 changes: 23 additions & 0 deletions runner/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -ue

DEPOT=$1
shift

mkdir $DEPOT

mkdir -p /storage/artifacts
ln -s /storage/artifacts $DEPOT/artifacts

# allow identification of PkgEal
export CI=true
export PKGEVAL=true
export JULIA_PKGEVAL=true

# disable system discovery of Python and R
export PYTHON=""
export R_HOME="*"

# no automatic precompilation
export JULIA_PKG_PRECOMPILE_AUTO=0

exec "$@"
48 changes: 19 additions & 29 deletions src/run.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export Configuration

function prepare_runner()
for runner in ("ubuntu", "arch")
cd(joinpath(dirname(@__DIR__), "runner.$runner")) do
cmd = `docker build --tag newpkgeval:$runner .`
cd(joinpath(dirname(@__DIR__), "runner")) do
for runner in ("ubuntu", "arch")
cmd = `docker build --tag newpkgeval:$runner --file Dockerfile.$runner .`
if !isdebug(:docker)
cmd = pipeline(cmd, stdout=devnull, stderr=devnull)
end
Expand Down Expand Up @@ -44,7 +44,9 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
storage=nothing, cache=nothing, sysimage=nothing,
runner="ubuntu", depot="/home/pkgeval/.julia",
xvfb::Bool=true, init::Bool=true)
cmd = `docker run`
## Docker args

cmd = `docker run --rm`

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

# allow identification of PkgEval
cmd = `$cmd --env CI=true --env PKGEVAL=true --env JULIA_PKGEVAL=true`

# disable system discovery of Python and R
cmd = `$cmd --env PYTHON="" --env R_HOME="*"`

if storage !== nothing
cmd = `$cmd --mount type=bind,source=$storage,target=/storage`
end
Expand All @@ -77,10 +72,6 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
cmd = `$cmd --mount type=bind,source=$cache,target=/cache`
end

if sysimage !== nothing
args = `--sysimage=$sysimage $args`
end

# mount working directory in tmpfs
if tmpfs
cmd = `$cmd --tmpfs /home/pkgeval:exec,uid=1000,gid=1000`
Expand Down Expand Up @@ -110,10 +101,19 @@ function runner_sandboxed_julia(install::String, args=``; interactive=true, tty=
cmd = `$cmd --init`
end

cmd = `$cmd newpkgeval:$runner`


## Julia args

if sysimage !== nothing
args = `--sysimage=$sysimage $args`
end

if xvfb
`$cmd --rm newpkgeval:$runner xvfb-run /opt/julia/bin/julia $args`
`$cmd $depot xvfb-run /opt/julia/bin/julia $args`
else
`$cmd --rm newpkgeval:$runner /opt/julia/bin/julia $args`
`$cmd $depot /opt/julia/bin/julia $args`
end
end

Expand Down Expand Up @@ -146,12 +146,6 @@ function run_sandboxed_test(install::String, pkg; log_limit = 2^20 #= 1 MB =#,
versioninfo()
println()
mkpath(first(DEPOT_PATH))
# global storage of downloaded artifacts
mkpath("/storage/artifacts")
symlink("/storage/artifacts", joinpath(first(DEPOT_PATH), "artifacts"))
using Pkg
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
Expand Down Expand Up @@ -385,12 +379,6 @@ function run_compiled_test(install::String, pkg; compile_time_limit=30*60, cache
versioninfo()
println()
mkpath(first(DEPOT_PATH))
# global storage of downloaded artifacts
mkpath("/storage/artifacts")
symlink("/storage/artifacts", joinpath(first(DEPOT_PATH), "artifacts"))
using Pkg
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
Expand Down Expand Up @@ -504,6 +492,7 @@ function run(configs::Vector{Configuration}, pkgs::Vector;
for (config, (install,cache)) in instantiated_configs
Base.run(```docker run --mount type=bind,source=$storage,target=/storage
--mount type=bind,source=$cache,target=/cache
--entrypoint=''
newpkgeval:ubuntu
sudo chown -R pkgeval:pkgeval /storage /cache```)
end
Expand Down Expand Up @@ -744,6 +733,7 @@ function run(configs::Vector{Configuration}, pkgs::Vector;
uid = ccall(:getuid, Cint, ())
gid = ccall(:getgid, Cint, ())
Base.run(```docker run --mount type=bind,source=$cache,target=/cache
--entrypoint=''
newpkgeval:ubuntu
sudo chown -R $uid:$gid /cache```)
rm(cache; recursive=true)
Expand Down

0 comments on commit 1055cff

Please sign in to comment.