I want to build a docker image with Julia packages ready to go.
What are best practices for that?
Here’s what I got so far:
FROM julia
RUN julia install.jl
where install.jl
is:
using Pkg
packages = ["JSON", "CSV"]
Pkg.add(packages)
using CSV, JSON
Is there any way to precompile an array of packages?
From the docs I thought that Pkg.build
accepts array of packages (same as Pkg.add
) but it throws an error:
Pkg.build(packages)
ERROR: MethodError: no method matching Pkg.Types.PackageSpec(::Array{String,1})
Closest candidates are:
Pkg.Types.PackageSpec(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Pkg\src\Types.jl:91
Pkg.Types.PackageSpec(; name, uuid, version, tree_hash, repo, path, pinned, mode) at util.jl:742
Pkg.Types.PackageSpec(::Union{Nothing, String}, ::Union{Nothing, Base.UUID}, ::Union{Pkg.Types.UpgradeLevel, VersionNumber, Pkg.Types.VersionSpec}, ::Union{Nothing, Base.SHA1}, ::Pkg.Types.GitRepo, ::Union{Nothing, String}, ::Bool, ::Pkg.Types.PackageMode) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Pkg\src\Types.jl:91
...
Stacktrace:
[1] iterate at .\generator.jl:47 [inlined]
[2] collect(::Base.Generator{Tuple{Array{String,1}},Type{Pkg.Types.PackageSpec}}) at .\array.jl:665
[3] #build#105 at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Pkg\src\API.jl:677 [inlined]
[4] build(::Array{String,1}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Pkg\src\API.jl:677
[5] top-level scope at REPL[4]:1
Although if I hardcode the array it works:
Pkg.add(["CSV", "JSON"])
But I want to avoid typing modules list twice. How can I do that?