Julia
This page covers the requirements and internals of deploying Julia content to ricochet.
Project requirements
Section titled “Project requirements”Every Julia deployment requires a Manifest.toml file in the project root.
This lockfile is generated by Julia’s built-in package manager (Pkg) and records all package dependencies and their versions.
Example _ricochet.toml
Section titled “Example _ricochet.toml”[content]name = "My Dash.jl App"entrypoint = "app.jl"access_type = "external"content_type = "julia-service"
[language]name = "julia"packages = "Manifest.toml"
[serve]min_instances = 0max_instances = 5Supported content types
Section titled “Supported content types”Julia content items can be deployed as apps or tasks.
Content Type | Description |
|---|---|
julia-service | A web app or API using a Julia runtime such as Dash.jl. |
Content Type | Description |
|---|---|
julia | A Julia script. |
quarto-jl | A Quarto document using a Julia runtime. Can be served as a static site. |
How ricochet runs Julia content
Section titled “How ricochet runs Julia content”Julia version discovery
Section titled “Julia version discovery”Julia must be installed via juliaup.
Only juliaup-managed Julia installations are supported.
Ricochet vendors juliaup at $RICOCHET_HOME/vendor.
juliaup add <version>When a deployment is received, ricochet uses juliaup to discover installed Julia channels and selects the appropriate version.
Environment restoration
Section titled “Environment restoration”When a bundle is deployed, ricochet restores Julia package dependencies from the Manifest.toml file using Julia’s built-in package manager.
Using the API
Section titled “Using the API”You can deploy and manage Julia content programmatically using the ricochet REST API.
The examples below use HTTP.jl.
API keys are created in the ricochet UI under Credentials → API Keys.
Deploy a bundle
Section titled “Deploy a bundle”Bundle your project as a .tar.gz archive and upload it with the _ricochet.toml config.
using HTTP, JSON3, Tar, CodecZlib
server = "https://try.ricochet.rs"api_key = ENV["RICOCHET_API_KEY"]headers = ["Authorization" => "Key $api_key"]
# Create a tar.gz bundle of the project directorybundle_path = tempname() * ".tar.gz"open(bundle_path, "w") do io gz = GzipCompressorStream(io) Tar.create(".", gz) close(gz)end
# Deploy new contentbody = HTTP.Form(Dict( "bundle" => HTTP.Multipart("bundle.tar.gz", open(bundle_path), "application/gzip"), "config" => HTTP.Multipart("_ricochet.toml", open("_ricochet.toml"), "application/toml"),))resp = HTTP.post("$server/api/v0/content/upload", headers, body)result = JSON3.read(resp.body)result.id#> "01JSZAXZ3TSTAYXP56ARDVFJCJ"To redeploy existing content, pass id instead of config:
body = HTTP.Form(Dict( "bundle" => HTTP.Multipart("bundle.tar.gz", open(bundle_path), "application/gzip"), "id" => "01JSZAXZ3TSTAYXP56ARDVFJCJ",))resp = HTTP.post("$server/api/v0/content/upload", headers, body)Invoke a task
Section titled “Invoke a task”content_id = "01JSZAXZ3TSTAYXP56ARDVFJCJ"
resp = HTTP.post( "$server/api/v0/content/$content_id/invoke", ["Authorization" => "Key $api_key", "Content-Type" => "application/json"], JSON3.write(Dict("params" => Dict("n" => 100))),)JSON3.read(resp.body)List your content
Section titled “List your content”resp = HTTP.get("$server/api/v0/user/items", headers)items = JSON3.read(resp.body)