Deployments

Introduction

In this tutorial you will learn how to deploy your projects as long running services.

Creating a deployable Project

To create a deployable project, navigate to the 'Projects' tab from the left menu bar.

projects

Once you are in the projects section click the 'Create project' button.

create_project

If this is your first time working with deployments on JuliaHub we recommend that you select the "Web application" template. The web application template is based on HTTP.jl, a pure Julia HTTP server library. It provides a simple starting point for building and hosting web servers and interactive applications directly on JuliaHub.

templates

If you selected one of "Generic Project" or "Import Project" options, check the "Deployable" box on the bottom left. You can also convert the project to deployable later.

In the next step, you will be required to provide the name of your project and give it a description. You can also provide tags and choose the default editor application. You will also need to select the workflow type: Group Editing or Exclusive Editing.

In the third step of the setup, you can add collaborators such as groups or a single user and grant them different access levels.

[!IMPORTANT] Note that a minimum of "Editor" access is required for a user on a project to be allowed to deploy that project.

Configure the hosting options for your deployments. At this stage, the options are only saved. The instance will be started only when you deploy your project via the "Deploy" button later.

hosting options

  • Select machine type for deployment: Select the size of machine indicated by number of CPUs and size of RAM.
  • DNS: Select whether you want the domain name for the project deployment to be auto-generated or reserved. If you selected auto-generate, a different domain name will be generated for each deployment. If you selected "Reserved", then you get to choose from your list of reserved domain names.
  • Port number: The port number that will be proxied and exposed.
  • Access Options: Select the access option for your project deployment. If you selected "Just me", only you are allowed to access the deployment. If you selected "Logged in users", any user logged in to JuliaHub can access your project through the selected domain name. Choose password protected if you want to enforce a password to access your deployment. Finally "Totally public" disables authentication for the project deployment.

You can edit these settings later by clicking "Settings" in the Deploy button dropdown.

[!IMPORTANT] A deployed app exposes every HTTP route it serves. Anyone in the access group you choose can reach every HTTP route your application serves at its URL — including routes registered by the packages it depends on, not just the routes you wrote. Some web and development packages register administrative routes (for evaluating code, browsing or editing files, or opening a REPL) when run in their default development configuration. Before deploying — especially with the fully public option — make sure your application does not load development or debugging tooling, and if the framework you use has a production setting, enable it. Never hard-code credentials or API tokens in a publicly accessible app; use JuliaHub's encrypted secrets instead. Prefer a restricted access option unless the app is genuinely meant for the open internet.

Once you have completed this stage, you will see the project added to your projects.

newproject

Click on the project to see the details of the project.

screen2

Developing with Julia IDE

You can edit the files on your project by clicking on the "Launch" button to open an editor. Alternatively, you can upload files by clicking the 'Import file' button.

To deploy your project, you will need a Manifest.toml file. If your project does not have Manifest.toml generated, follow the next steps.

Click the 'Launch' button to start an editor session. You will then be redirected to a VS Code tab automatically once the editor is ready.

In VS Code, right click the 'Project.toml' file and then click 'Julia: Activate this Environment' in the dropdown menu.

project.toml

After that in the Julia terminal type: ] to enter package mode and insert 'instantiate' and press the Enter key.

instantiate

You will see a Manifest.toml file is generated. After that go to source control and commit changes.

manifest

Go back to your JuliaHub project page. If you created a Group editing project click the 'Publish' button to pull your new Manifest.toml file. If you created an Exclusive editing project you don't have to do anything at this stage.

Testing your code

It is convenient to run and test your project code inside the editor before deploying it on the platform.

Click on the main.jl file in the file menu:

Click on main.jl

Activate the environment by selecting "Julia: Activate this environment" from the ... menu. Thereafter, run the script by clicking the play button:

Activate and run

Once you run this script in the JuliaHub IDE, you should see the following dialog on the bottom right side of the screen:

Port Forward Dialog

Once you click on "Open in Browser" you should see your web application correctly rendered.

[!IMPORTANT] By default, JuliaHub IDE proxies requests. Make sure your server listens on Sockets.localhost (not 0.0.0.0) so it responds correctly through the proxy.

Deploying your project

Click the 'Deploy' button to deploy the project as a dedicated, long-running container. If you created a Group editing project the Deploy button is made available in the 'Source' tab.

screen2

Your deployed application will be opened in a new tab automatically when it's ready. The 'Deploy' button will also change to 'Connect' at this point, so you can also click this button.

Congrats! You now have a web application deployed on JuliaHub.

Suspending and resuming your deployment

Deployments can be suspended to save on costs. Suspending a deployment will de-allocate its hardware resources. To suspend a deployment, click on "Suspend" in the drop down list next to the Deploy button.

To resume the deployment click on "Wake up" in the same drop down menu.

scaling

Sharing your deployment with others

In the drop down list next to the Deploy button, click on Settings. Configure access to the deployment as desired (See access options above). In the same drop down list click on "Copy link". This will give you an HTML snippet that you can paste on your web pages. This snippet will render as a button that links back to your web application.

copy_link

Deployment dashboard and past deployments

On your project page, click on the "Deployments" tab. Here you will see the details of the current deployment if you have one running along with buttons to stop, suspend or connect to the deployment. These buttons are just replicas of what you already have in the deploy button's drop down list.

Below "Active Deployment", you can access a list of past deployments. Clicking on one of the past deployments opens the details page for that deployment.

deployments dashboard

Listing your deployments

The "Deployments" main menu item on the left panel has an indicator displaying the number of currently active deployments across all your projects. Click on the Deployments menu item to open the Deployments page. Here you can see a list of currently active deployments as well as older terminated deployments. Clicking on any of the items opens the details page for that deployment. There is also a link back to the parent project on each of the rows.

deployments page

Converting your regular projects to deployable projects

If you created a regular project and you now want to deploy it, you must first convert it to a deployable project. Click on the "Manage" drop down and select "Edit Metadata". Check the "Deployable" checkbox and then click "Update". Confirm the dialog to convert your project to a deployable project. The Deploy button will now be enabled for your project.

convert deployment

Note that you cannot convert a regular project to a deployable project if you have any project batch jobs running. In this case the confirm dialog will tell you about the active jobs. You need to stop these jobs or wait for their completion before you can convert your project. Note also that you can no longer access the project jobs tab once you do this. Project deployments and project batch jobs are mutually exclusive.

Converting your deployable project to regular project

If you want to disable the deployment feature on a project or you want to use the batch job feature on a deployable project, you can convert your deployable project to a regular project. Just as with converting a regular project to a deployable project, converting it back requires that you have no active deployment running. You will have to terminate the active deployment before you convert your project back. The confirm dialog will tell you about this. You will also lose access to the Deployments tab. The "Start Job" button and "Jobs" tab will re-appear when you convert a deployable project to a regular project.


Resources and Examples