diff --git a/.drone.star b/.drone.star index 7c129d3..248eb09 100644 --- a/.drone.star +++ b/.drone.star @@ -9,6 +9,11 @@ SPLUNK_VERSIONS = ("9.1", "9.2", "9.3") UBUNTU_VERSIONS = ("24.04",) TEMPLATES = { + "_app": { + "thug": { + "image": "cr.smcm.xyz/coder-images/thug", + } + }, "_distro": { "alpine": { "distro_name": "Alpine Linux", diff --git a/_app.tf.j2 b/_app.tf.j2 new file mode 100644 index 0000000..c6dae43 --- /dev/null +++ b/_app.tf.j2 @@ -0,0 +1,121 @@ +{% extends "base.tf.j2" %} + +{% block parameters %} +{{ super() }} + +{% if coder_parameters %} +{% for param in coder_parameters %} +data "coder_parameter" "{{ param.name }}" { + name = "{{ param.display_name | default(param.name) }}" + ephemeral = {{ param.ephemeral | default("false", true) }} + mutable = {{ param.mutable | default("true", true) }} + type = "{{ param.type | default("string")}}" + + {% if param.default %} + default = "{{ param.default }}" + {% endif %} + {% if param.description %} + description = "{{ param.description }}" + {% endif %} + {% if param.display_name %} + display_name = "{{ param.display_name }}" + {% endif %} + {% if param.form_type %} + form_type = "{{ param.form_type }}" + {% endif %} + {% if param.icon %} + icon = "{{ param.icon }}" + {% endif %} + {% if param.order %} + order = {{ param.order }} + {% endif %} + {% if param.styling %} + styling = "{{ param.styling }}" + {% endif %} + + {% for option in param.options %} + option { + {% if hasattr(option, "items") %} + name = "{{ option.name }}" + value = "{{ option.value | default(option.name) }}" + {% if option.description %} + description = "{{ option.description }}" + {% endif %} + {% if option.icon %} + icon = "{{ option.icon }}" + {% endif %} + {% else %} + name = "{{ option }}" + value = "{{ option }}" + {% endif %} + } + {% endfor %} + + {% if param.validation %} + + {% endif %} +} +{% endfor %} +{% endif %} +{% endblock %} + +{% block coder_apps %} +{% if coder_apps %} +{% for app in coder_apps %} +resource "coder_app" "jupyter" { + agent_id = coder_agent.main.id + display_name = {{ app.display_name }} + slug = {{ app.slug }} + icon = {{ app.icon }} + url = {{ app.url }} + subdomain = true + share = "owner" + + {% if app.healthcheck %} + healthcheck { + url = {{ app.healthcheck.url }} + interval = {{ app.healthcheck.interval | default(3) }} + threshold = {{ app.healthcheck.threshold | default (10) }} + } + {% endif %} +} +{% endfor %} +{% endif %} +{% endblock %} + +{% block kubernetes_pod_extra_env %} +{% if envvars %} +{% for envvar in envvars %} + env { + name = "{{ envvar.name | upper() }}" + value = "{{ envvar.value }}" + } +{% endfor %} +{% endif %} +{% endblock %} + +{% block kubernetes_pod_main_volume_mount %} +{% if main_volume_mount_path %} + volume_mount { + mount_path = "{{ main_volume_mount_path }}" + name = "home" + read_only = false + } +{% else %} +{{ super() }} +{% endif %} +{% endblock %} + +{% block post_startup_script_setup_home %} +{% if startup_script %} + {{ startup_script }} +{% endif %} +{% endblock %} + +{% block kubernetes_pod_main_image %} +{% if ":" in image %} + image = "{{image}}" +{% else %} + image = "{{image}}:latest" +{% endif %} +{% endblock %} \ No newline at end of file diff --git a/jupyter.tf.j2 b/jupyter.tf.j2 deleted file mode 100644 index a5441f8..0000000 --- a/jupyter.tf.j2 +++ /dev/null @@ -1,39 +0,0 @@ -{% extends "base.tf.j2" %} - -{% block coder_apps %} -resource "coder_app" "jupyter" { - agent_id = coder_agent.main.id - display_name = "Jupyter lab" - slug = "jupyter" - icon = "/icon/jupyter.svg" - url = "http://localhost:8888/" - subdomain = true - share = "owner" - - healthcheck { - url = "http://localhost:8888/api" - interval = 3 - threshold = 10 - } -} -{% endblock %} - -{% block kubernetes_pod_main_env %} - env { - name = "CONDA_ENVS_PATH" - value = "/home/jovyan/envs" - } - env { - name = "DOCKER_STACKS_JUPYTER_CMD" - value = "lab" - } - env { - name = "NOTEBOOK_ARGS" - value = "--no-browser --ServerApp.token='' --ip='*'" - } -{{ super() }} -{% endblock %} - -{% block post_startup_script_setup_home %} - /usr/local/bin/start-notebook.sh | tee jupyter-startup.log & -{% endblock %} \ No newline at end of file