C
Coder.com•6mo ago
Immuc

Question about Docker-Template

Why is the installation script right here? Doesn't this section of code get run every time the container starts? Wouldn't it be better to move this into the dockerfile to just install it once?
No description
20 Replies
Codercord
Codercord•6mo ago
<#1248029748915998803>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Scott
Scott•6mo ago
I'd be interested in knowing this too. My best guess is, the realm of control. In the template, the Coder team have at least partial control over what is in the template (at least the examples) and if the install code changes, for instance they decide to make the agent a complete standalone app and not part of the Coder Server/ CLI app, then the install would change and they can update the templates. What I wish would be possible is template extensions, meaning, I can pull in a "base" template and only add the things in the extension I need to make it work. If the Coder team change the base template, like changing how the agent is installed and started, I don't need to worry about that, I only need to make sure I have an up-to-date base template. Not sure that is feasible, but it would be cool, if it were. 🙂
Atif
Atif•6mo ago
It can be moved into Dockerfile. IMO the examples are just to show what is possible. Users are expected to modify as per their needs. For production deployments it's better to move all installations into the Image, push the image to a registry and just use the built image instead of Coder building the image.
Phorcys
Phorcys•6mo ago
I've wondered that too and I usually recommend installing within the image. As Atif said I think this is a way to show what's possible but it does slow down workspace startup times. I think specifically for code-server it makes sense to install it every time to always have the latest version without having to update the image you don't really need to worry about the Coder Agent changing, that is already abstracted in the Terraform template, I think if the agent changed it would just be seamless. The agent is dynamic, it is downloaded on every startup from your Coder instance.
Scott
Scott•6mo ago
So, if the URL changed for instance to a new one, I wouldn't have to change it in my template?
Phorcys
Phorcys•6mo ago
you wouldn't, only have to change the access URL that's mainly what it's for as for the enterprise-base image, it is an image with all the minimal requirements to run the agent and modules (like wget/curl, jq) and some stuff you will likely want for Docker in Docker like SystemD and Docker
Scott
Scott•6mo ago
Exactly my point. 🙂 If there were to be a base template, I'd only have to worry about updating the base, not the URL. Less chance for mistakes. Easier to handle, etc.
Phorcys
Phorcys•6mo ago
I don't see what you mean your workspace has to know the Coder server's URL anyways it needs to communicate with it for status and anything you do through HTTPS rather than DERP because it acts as a middle man
Scott
Scott•6mo ago
Currently, we have to take an example template (or create one from scratch) and modify it for our needs. If any requirements to work with Coder change, like the URL for the agent install script, I have to manually update my templates (all of them). If there were a "base template" from which I had only extended all my other templates from, the changes to the base are automatically added as soon as I use the newer base template and basically all my templates are updated at the same time. In fact, just saying that, there must be a way to at least create extensible templates with Terraform. Let me check that. There are modules, I'm just not sure that covers what I'm thinking about.... Actually, it is. Hmm... https://coder.com/docs/templates/modules
Phorcys
Phorcys•6mo ago
oh, are you talking if the code-server IRL changes?
Scott
Scott•6mo ago
Yes. The URL to the install script. Just as an example of what might change.
Phorcys
Phorcys•6mo ago
oh yeah that isn't great
Scott
Scott•6mo ago
I haven't been dealing with Coder for some time now. It's just be going and going and going with little to no issues. So my memory is a bit lacking. LOL! 😄 Sorry to highjack your thread @Jackson. Your inquiry still stands. But, to bring the idea full circle to the subject and my thinking why the agent installation is in the template and not in the users' container, when creating a new template, Coder offers "starter templates". I feel these shouldn't be "starter templates" but rather starter "modules".
Scott
Scott•6mo ago
So, a template only references the "core" or "starter" or "base" module created by the Coder team. And if that module is changed by the Coder team, all I have to do is up the version to get those changes.
Phorcys
Phorcys•6mo ago
wait, you're saying you have to edit the Coder agent URL in all your templates?
Scott
Scott•6mo ago
Currently, yes. Because I haven't used modules. Or rather, I haven't looked into how scripts can be merged in modules.
Phorcys
Phorcys•6mo ago
we should move this to #general but TL;DR it should be automatic
Scott
Scott•6mo ago
@Jackson - Sorry again for the high-jacking of your thread. As it turns out, it was my own confusion about how the Agent is installed. The script you pointed out in your OP was for code-server. So also as @Phorcys pointed out, you could theoretically remove that code in your template and install it in your container image. You'd just have to make sure to "run it" in your startup_script (I believe).
Phorcys
Phorcys•6mo ago
hey @Jackson, does this answer your question?
Want results from more Discord servers?
Add your server