This commit is contained in:
Steve McMaster 2023-02-24 23:26:46 -05:00
parent 534927e112
commit 9344b539e3
2 changed files with 61 additions and 29 deletions

View File

@ -22,10 +22,37 @@ TEMPLATES = {
"splunk-python": {"image": "cr.smcm.xyz/coder-images/python-38:latest"},
},
"jupyter": {
"jupyter": {"image": "cr.smcm.xyz/coder-images/jupyter-scipy-notebook:latest"},
"jupyter-scipy-notebook": {"image": "cr.smcm.xyz/coder-images/jupyter-scipy-notebook:latest"},
},
}
def get_build_step(ctx, dockerfile, coder_template, path):
# {
# "name": "push templates",
# "image": "alpine:latest",
# "environment": {
# "CODER_URL": "http://coder.coder.svc.cluster.local",
# "CODER_SESSION_TOKEN": {
# "from_secret": "CODER_SESSION_TOKEN",
# },
# "CODER_TEMPLATE_VERSION": ctx.build.commit,
# },
# "commands": coder_commands,
# },
build_step =
for command in BUILD_COMMANDS:
build_step["commands"].append(command.format(
image = image,
DRONE_COMMIT_SHA = ctx.build.commit,
dockerfile = dockerfile,
path = path,
registry_base = registry_base,
))
return build_step
def get_jinja_command(template, output, context):
jinja2args = " ".join(["-D {key}={value}".format(key = key, value = value) for (key, value) in context.items()])
@ -36,11 +63,18 @@ def get_jinja_command(template, output, context):
)
def main(ctx):
pipeline = {
"kind": "pipeline",
"name": "default",
"type": "docker",
"steps": [],
}
jinja_commands = []
coder_commands = [
"apk add git",
"wget -q -O- {url} | tar -xzf - -C /usr/local/bin ./coder".format(url = CODER_URL),
]
# coder_commands = [
# "apk add git",
# "wget -q -O- {url} | tar -xzf - -C /usr/local/bin ./coder".format(url = CODER_URL),
# ]
for jinja_template in TEMPLATES:
for coder_template in TEMPLATES[jinja_template]:
@ -51,25 +85,8 @@ def main(ctx):
TEMPLATES[jinja_template][coder_template],
))
coder_commands.append(
" || ".join([
"coder templates push -d {name} --yes {name}".format(name = coder_template),
"coder templates create -d {name} --yes {name}".format(name = coder_template),
]),
)
return {
"kind": "pipeline",
"name": "default",
"type": "docker",
"steps": [
{
"name": "generate templates",
"image": "roquie/docker-jinja2-cli",
"commands": jinja_commands,
},
{
"name": "push templates",
pipeline["steps"].append({
"name": "push {coder_template}".format(coder_template = coder_template),
"image": "alpine:latest",
"environment": {
"CODER_URL": "http://coder.coder.svc.cluster.local",
@ -78,7 +95,21 @@ def main(ctx):
},
"CODER_TEMPLATE_VERSION": ctx.build.commit,
},
"commands": coder_commands,
},
],
}
"commands": [
"apk add git",
"wget -q -O- {url} | tar -xzf - -C /usr/local/bin ./coder".format(url = CODER_URL),
" || ".join([
"coder templates push -d {name} --yes {name}".format(name = coder_template),
"coder templates create -d {name} --yes {name}".format(name = coder_template),
]),
],
"depends_on": [
"generate templates",
],
})
pipeline["steps"].insert(0, {
"name": "generate templates",
"image": "roquie/docker-jinja2-cli",
"commands": jinja_commands,
})

View File

@ -10,7 +10,7 @@ resource "coder_app" "jupyter" {
share = "public"
healthcheck {
url = "http://localhost:8888/lab"
url = "http://localhost:8888/api"
interval = 3
threshold = 10
}
@ -30,4 +30,5 @@ resource "coder_app" "jupyter" {
{% endblock %}
{% block post_startup_script_setup_home %}
/usr/local/bin/start-notebook.sh | tee jupyter-startup.log &
{% endblock %}