C
Coder.com•3y ago
subz

Coder Workspaces as code

Hi, i came across an example from @Ben where he has a solution pretty much like how Gitpod/Github codespaces has where the end developer can open a new workspace(WS) that automates developer experience. example: https://github.com/bpmct/bookshop-monorepo/blob/main/.coder/coder.yaml v1 docs: https://coder.com/docs/coder/latest/workspaces/workspace-templates/templates I cannot find anything like that for Coder OSS (v2) ... Is V2 backward compatible? image: value: bencdr/bookshop-coder:latest
GitHub
bookshop-monorepo/coder.yaml at main · bpmct/bookshop-monorepo
A sample monorepo with multiple services for running a bookshop's inventory - bookshop-monorepo/coder.yaml at main · bpmct/bookshop-monorepo
Workspace templates - Coder v1 v1.37 docs
Learn how to write a template for creating workspaces.
9 Replies
Phorcys
Phorcys•3y ago
definitely not backwards compatible
Phorcys
Phorcys•3y ago
you should check out the templates here https://github.com/coder/coder/tree/main/examples/templates
GitHub
coder/examples/templates at main · coder/coder
A tool that provisions remote development environments via Terraform - coder/examples/templates at main · coder/coder
subz
subzOP•3y ago
how can i automate the dev environment? what i want to achieve is open a repo with one click, have the vscode extensions downloaded and some scripts run ... i cannot find any docs for this on v2
Phorcys
Phorcys•3y ago
using commands you use the startup_script command of the coder agent
subz
subzOP•3y ago
could you please provide an example on Github
Phorcys
Phorcys•3y ago
@subz pick any of the templates here and modify the startup script I will mention that v1 and v2 are very different though you should read the docs, v2 leverages terraform for your workspaces, which means your workspaces can run on docker, kubernetes, aws, gcp, etc you'll have to choose the proper template that fits your needs
Atif
Atif•3y ago
@Phorcys I believe a github action can be created that uses the coder token to create a workspace and install the dependencies. This can be triggered on a click workflow_dispatch I do not know how it can done exactly. But I may try to create an action template to achieve this next month after my semester ends.
bpmct
bpmct•2y ago
We're planning on creating an "Open in Coder" experience in the near future, similar to that in v1. In the meantime, yes there are workarounds to automatically create a workspace with the CLI or REST API. However, there's no way to auto-clone a git repo if the user isn't authenticated yet or pre-fill parameter values. We want the experience to be magical for devs: navigate to repo -> click "Open". The DevOps should be responsible for how that magic works under the hood though, so you'll be able to do a lot with it (e.g. clone multiple repos, specify custom params per button, etc) 🙂 Stay tuned - I'll link an issue here once we have something more concrete
bpmct
bpmct•2y ago
In the meantime, here's a button you can embed in your repos that just links to the template page. Not quite a magical experience since the dev needs to enter values, but we'll get there 😄

Did you find this page helpful?