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

**URL:** <https://discourse.julialang.org/t/julia-system-image-including-packages-to-be-executed-in-gcp-dataflow/11583>\
**Category:** General Usage\
**Tags:** package\
**Created:** [June 11, 2018, 1:17pm UTC](https://discourse.julialang.org/t/julia-system-image-including-packages-to-be-executed-in-gcp-dataflow/11583 "2018-06-11T13:17:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![guillempuig1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/guillempuig1/32/4294_2.png) [@guillempuig1](https://discourse.julialang.org/u/guillempuig1)\
**Post date:** [June 11, 2018, 1:17pm UTC](https://discourse.julialang.org/t/julia-system-image-including-packages-to-be-executed-in-gcp-dataflow/11583/1 "2018-06-11T13:17:39Z")

</div>

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:

```julia
##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

```julia
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:

```julia
#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.

```

```julia
Option2
#Modify the REQUIRE file adding my packages names as a list

```

```julia
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

```julia
##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:

```julia
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
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,
