Anooj commited on
Commit
1c6a4dd
1 Parent(s): a1e5d79

added precompilation

Browse files
Files changed (6) hide show
  1. Dockerfile +8 -2
  2. Manifest.toml +27 -0
  3. Project.toml +2 -0
  4. make.jl +10 -0
  5. packages.jl +30 -0
  6. precompile.jl +47 -0
Dockerfile CHANGED
@@ -4,9 +4,15 @@ RUN useradd --create-home --shell /bin/bash genie
4
  RUN mkdir /home/genie/app
5
  COPY . /home/genie/app
6
  WORKDIR /home/genie/app
 
 
 
 
7
  RUN chown -R genie:genie /home/
8
  USER genie
9
 
 
 
10
  EXPOSE 8000
11
  EXPOSE 80
12
  ENV JULIA_DEPOT_PATH "/home/genie/.julia"
@@ -18,6 +24,6 @@ ENV WSPORT "8000"
18
  RUN julia -e 'using Pkg; Pkg.add(url="https://github.com/anoojpatel/Chess.jl"); Pkg.activate("."); Pkg.add("Stipple"); Pkg.precompile()'
19
 
20
  # Compile app
21
- #RUN julia --project make.jl
22
 
23
- ENTRYPOINT julia --project -e 'using Pkg; Pkg.instantiate(); using Genie; Genie.loadapp(); up(async=false);;'
 
4
  RUN mkdir /home/genie/app
5
  COPY . /home/genie/app
6
  WORKDIR /home/genie/app
7
+
8
+ # C compiler for PackageCompiler before non-root user is set
9
+ RUN apt-get update && apt-get install -y g++
10
+
11
  RUN chown -R genie:genie /home/
12
  USER genie
13
 
14
+
15
+
16
  EXPOSE 8000
17
  EXPOSE 80
18
  ENV JULIA_DEPOT_PATH "/home/genie/.julia"
 
24
  RUN julia -e 'using Pkg; Pkg.add(url="https://github.com/anoojpatel/Chess.jl"); Pkg.activate("."); Pkg.add("Stipple"); Pkg.precompile()'
25
 
26
  # Compile app
27
+ RUN julia --project make.jl
28
 
29
+ ENTRYPOINT julia --project --sysimage=sysimg.so -e 'using Pkg; Pkg.instantiate(); using Genie; Genie.loadapp(); up(async=false);;'
Manifest.toml CHANGED
@@ -303,6 +303,10 @@ git-tree-sha1 = "f2355693d6778a178ade15952b7ac47a4ff97996"
303
  uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
304
  version = "1.3.0"
305
 
 
 
 
 
306
  [[deps.LibCURL]]
307
  deps = ["LibCURL_jll", "MozillaCACerts_jll"]
308
  uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
@@ -442,6 +446,12 @@ git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
442
  uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
443
  version = "1.4.1"
444
 
 
 
 
 
 
 
445
  [[deps.Parameters]]
446
  deps = ["OrderedCollections", "UnPack"]
447
  git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe"
@@ -464,6 +474,11 @@ git-tree-sha1 = "a6062fe4063cdafe78f4a0a81cfffb89721b30e7"
464
  uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
465
  version = "1.4.2"
466
 
 
 
 
 
 
467
  [[deps.Preferences]]
468
  deps = ["TOML"]
469
  git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d"
@@ -493,6 +508,12 @@ git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
493
  uuid = "189a3867-3050-52da-a836-e630ba90ab69"
494
  version = "1.2.2"
495
 
 
 
 
 
 
 
496
  [[deps.Requires]]
497
  deps = ["UUIDs"]
498
  git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
@@ -520,6 +541,12 @@ git-tree-sha1 = "2c761a91fb503e94bd0130fcf4352166c3c555bc"
520
  uuid = "76ed43ae-9a5d-5a62-8c75-30186b810ce8"
521
  version = "3.40.0+1"
522
 
 
 
 
 
 
 
523
  [[deps.Serialization]]
524
  uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
525
 
 
303
  uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
304
  version = "1.3.0"
305
 
306
+ [[deps.LazyArtifacts]]
307
+ deps = ["Artifacts", "Pkg"]
308
+ uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
309
+
310
  [[deps.LibCURL]]
311
  deps = ["LibCURL_jll", "MozillaCACerts_jll"]
312
  uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
 
446
  uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
447
  version = "1.4.1"
448
 
449
+ [[deps.PackageCompiler]]
450
+ deps = ["Artifacts", "LazyArtifacts", "Libdl", "Pkg", "Printf", "RelocatableFolders", "TOML", "UUIDs"]
451
+ git-tree-sha1 = "b7042b6eff5434407d8bc4b48470ac4c708b1f8c"
452
+ uuid = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
453
+ version = "2.1.3"
454
+
455
  [[deps.Parameters]]
456
  deps = ["OrderedCollections", "UnPack"]
457
  git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe"
 
474
  uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
475
  version = "1.4.2"
476
 
477
+ [[deps.PrecompileSignatures]]
478
+ git-tree-sha1 = "18ef344185f25ee9d51d80e179f8dad33dc48eb1"
479
+ uuid = "91cefc8d-f054-46dc-8f8c-26e11d7c5411"
480
+ version = "3.0.3"
481
+
482
  [[deps.Preferences]]
483
  deps = ["TOML"]
484
  git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d"
 
508
  uuid = "189a3867-3050-52da-a836-e630ba90ab69"
509
  version = "1.2.2"
510
 
511
+ [[deps.RelocatableFolders]]
512
+ deps = ["SHA", "Scratch"]
513
+ git-tree-sha1 = "90bc7a7c96410424509e4263e277e43250c05691"
514
+ uuid = "05181044-ff0b-4ac5-8273-598c1e38db00"
515
+ version = "1.0.0"
516
+
517
  [[deps.Requires]]
518
  deps = ["UUIDs"]
519
  git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
 
541
  uuid = "76ed43ae-9a5d-5a62-8c75-30186b810ce8"
542
  version = "3.40.0+1"
543
 
544
+ [[deps.Scratch]]
545
+ deps = ["Dates"]
546
+ git-tree-sha1 = "f94f779c94e58bf9ea243e77a37e16d9de9126bd"
547
+ uuid = "6c6a2e73-6563-6170-7368-637461726353"
548
+ version = "1.1.1"
549
+
550
  [[deps.Serialization]]
551
  uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
552
 
Project.toml CHANGED
@@ -6,6 +6,8 @@ version = "0.1.0"
6
  [deps]
7
  Chess = "717200cc-f167-4fd3-b4bf-b5e480529844"
8
  Genie = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
 
 
9
  Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
10
  StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
11
  Stipple = "4acbeb90-81a0-11ea-1966-bdaff8155998"
 
6
  [deps]
7
  Chess = "717200cc-f167-4fd3-b4bf-b5e480529844"
8
  Genie = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
9
+ PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
10
+ PrecompileSignatures = "91cefc8d-f054-46dc-8f8c-26e11d7c5411"
11
  Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12
  StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
13
  Stipple = "4acbeb90-81a0-11ea-1966-bdaff8155998"
make.jl ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ using PackageCompiler
2
+
3
+ include("packages.jl")
4
+
5
+ PackageCompiler.create_sysimage(
6
+ PACKAGES,
7
+ sysimage_path = "sysimg.so",
8
+ precompile_execution_file = "precompile.jl",
9
+ cpu_target = PackageCompiler.default_app_cpu_target()
10
+ )
packages.jl ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using Pkg
2
+
3
+ function list_packages()
4
+ deps = Pkg.dependencies()
5
+ installs = Dict{String, Vector{Any}}()
6
+
7
+ for (uuid, dep) in deps
8
+ dep.is_direct_dep || continue
9
+ dep.version === nothing && continue
10
+ dep.source === nothing && continue
11
+ moddevdir = false
12
+
13
+ if haskey(ENV, "JULIA_PKG_DEVDIR")
14
+ moddevdir = true
15
+ end
16
+
17
+ if moddevdir && occursin(ENV["JULIA_PKG_DEVDIR"], dep.source)
18
+ installs[dep.name] = [dep.version, "dev"]
19
+ elseif !moddevdir && !isempty(findall(x -> x == "dev", splitpath(dep.source)))
20
+ installs[dep.name] = [dep.version, "dev"]
21
+ else
22
+ installs[dep.name] = [dep.version, ""]
23
+ end
24
+
25
+ end
26
+
27
+ return installs
28
+ end
29
+
30
+ const PACKAGES = [pkg for pkg in keys(list_packages())]
precompile.jl ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using Genie
2
+
3
+
4
+ Genie.loadapp(pwd())
5
+
6
+ include("packages.jl")
7
+ using PrecompileSignatures
8
+
9
+ for p in PACKAGES
10
+ @show "Precompiling signatures for $p"
11
+ Core.eval(@__MODULE__, Meta.parse("import $p"))
12
+ Core.eval(@__MODULE__, Meta.parse("@precompile_signatures($p)"))
13
+ end
14
+
15
+ import Genie.Requests.HTTP
16
+
17
+ @info "Hitting routes"
18
+
19
+ for r in Genie.Router.routes()
20
+ try
21
+ r.action()
22
+ catch
23
+ end
24
+ end
25
+
26
+ const PORT = 8000
27
+
28
+ try
29
+ @info "Starting server"
30
+ up(PORT)
31
+ catch
32
+ end
33
+
34
+ rts = Genie.Router.routes()
35
+
36
+ try
37
+ for rt in rts
38
+ @time HTTP.request("GET", "http://localhost:$PORT" * rt.path)
39
+ end
40
+ catch
41
+ end
42
+
43
+ try
44
+ @info "Stopping server"
45
+ Genie.Server.down!()
46
+ catch
47
+ end