Julia system image including packages (to be executed in GCP dataflow)

package

#1

Hello everyone!

I’m trying to build a Julia system image with the aim of having all my needed packages included within this image beacuse I need to use this image in Google Cloud Platform (Dataflow).

The objectif is to be able to reduce as much as possible the startup time of Julia in the cloud.
I’m using Docker to do the tests. The idea has been to use a Docker Julia Image to build a sys.ji which normally should include all the desired packages.

So, until now what I have used is:

##1 Creating "build_sysimg.jl"
include(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "build_sysimg.jl"))
build_sysimg()
build_sysimg(force=true)

By doing this step I’m creating my sys.ji image

INFO: System image successfully built at /tmp/sys.ji.
INFO: To run Julia with this image loaded, run: `julia -J /tmp/sys.ji`

After that I am creating a ~/userimg.jl file where I have tried several things to include my packages:

#Option 1
function add_to_path(directory)
        if isdir(directory)
                push!(LOAD_PATH, directory)
        end
end

add_to_path("/root/.julia/v0.6/")

Prior to that I had included the Packages manually by Pkg.add("package") with the aim of having all required packages in the ../../v0.6 PATH and after that being able to add them to the startup things to do by Julia.
Option2
#Modify the REQUIRE file adding my packages names as a list
Option 3 and 4
#Using both ~/.juliarc.jl and userimg.jl files with the following code:
opt 1 => Pkg.add("Package")
opt 2 => Base.require("package.jl")
opt 3 => include("package")

Once all those things tried, I have rebuild the sys.ji file

##2 rebuilding image
`julia path/to/build_sysimg.jl tmp/sys native path/to/juliarc.jl or userimg.jl  --force`

and normally I have the same message as before:

INFO: System image successfully built at /tmp/sys.ji.
INFO: To run Julia with this image loaded, run: `julia -J /tmp/sys.ji`

The if I run the command: julia -J /tmp/sys.ji within the docker used and I do Pkg.installed() I am able to see all the packages I have installed.
BUT the problem is that to verify if the desired system image has been created I do:
docker cp container:path/to/sys.ji local_path
and then I copy this sys.ji to me new docker:
docker cp local_path/sys.ji container2:path/to/save/sys.ji

And when running julia -J /tmp/sys.ji within the new Docker and verifying Pkg.installed() I’m obtaining

julia> Pkg.installed()
Dict{String,VersionNumber} with 0 entries

So, the images used does not contain my packages.

I have tried lots of other thing but it is still not working. Any help?

RESUME: All I’m trying to do is to build a Julia System Image which contains the packages already copiled within it.

Do not hesitate to ask me for clarifications and more detailed explanations if needed,

Thanks you very much,