Coder.comC
Coder.com14mo ago
6 replies
Chris2pi

Creating a JupyterLab instance

It might be simple, but I can't get a JupyterLab instance going.
The goal is to spin up an AWS EC2 instance. I can do that with VSCode without issue.

I add the module from here but get a few errors on launch - https://registry.coder.com/modules/jupyterlab

Then I see this doco and it seems to be what the module is meant to do? https://coder.com/docs/admin/templates/extending-templates/web-ides#jupyterlab
Can't get that working either.

I suspect I am confusing the above doco and just using the module incorrectly and mixing it with the vscode out of the box template.

Code below

resource "coder_agent" "main" {
  os   = "linux"
  arch = "amd64"
  dir  = "/home/coder"

  startup_script = <<-EOT
    set -e

    pip3 install jupyterlab

    # install and start JupyterLab
    ~/.local/bin/jupyter lab --ServerApp.base_url=/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyter --ServerApp.token='' --ip='*'
  EOT
}

module "jupyterlab" {
  source   = "registry.coder.com/modules/jupyterlab/coder"
  version  = "1.0.23"
  agent_id = coder_agent.main.id
}

locals {
  linux_user = "coder"
  user_data  = <<-EOT
  Content-Type: multipart/mixed; boundary="//"
  MIME-Version: 1.0

  --//
  Content-Type: text/cloud-config; charset="us-ascii"
  MIME-Version: 1.0
  Content-Transfer-Encoding: 7bit
  Content-Disposition: attachment; filename="cloud-config.txt"

  #cloud-config
  cloud_final_modules:
  - [scripts-user, always]
  hostname: ${lower(data.coder_workspace.me.name)}
  users:
  - name: ${local.linux_user}
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash

  --//
  Content-Type: text/x-shellscript; charset="us-ascii"
  MIME-Version: 1.0
  Content-Transfer-Encoding: 7bit
  Content-Disposition: attachment; filename="userdata.txt"

  #!/bin/bash
  sudo -u ${local.linux_user} sh -c '${try(coder_agent.main.init_script, "")}'
  --//--
  EOT
}

Overall a end to end template would be nice. Happy to put one together once I understand it better.
A module that adds JupyterLab in your Coder template.
Add and configure Web IDEs in your templates as coder apps
Web IDEs and Coder Apps - Coder Docs
Preview image
Was this page helpful?