Coder is an open-source platform for creating and managing developer workspaces on your preferred cloud such as AWS, GCP, or Azure, and server environment.
By building on top of common development interfaces and infrastructure tools such as Terraform, Coder aims to make the process of provisioning and accessing remote workspaces approachable for organizations. Coder workspaces are represented with Terraform.
Reasons for remote development.
- Increased speed when it comes to IDE loading, code compilation, and running of large workloads such as those of microservices.
- Improved compatibility because remote workspaces share infrastructure configurations with others, this helps to reduce configuration issues.
- Terraform, Docker and other container-centric environments make developer onboarding and troubleshooting much easier.
- Increased security because cloud services are much more secure as compared to in-house data centers.
Terms to note
Agents
An agent
is a Coder service that runs within a user’s remote workspace. It provides a consistent interface for coderd
and clients to communicate with the workspace regardless of the operating system, or the cloud your infrastructure resides.
Coderd
It’s the service created whenever a coder server is run. Its a small API that connects workspaces and users together.
Provisionerd
This is the infrastructure provider, currently, it only has Terraform. Provisioners can have different Terraform versions that satisfy their own requirements.
Workspaces
This is a set of cloud resources such as VMs, Kubernetes clusters, storage buckets, etc.
Installing Coder in Google Cloud Platform
1. Setting up GCP VM
To begin installing the coder, we need to set up the Compute engine API. Go to create an instance and give an instance name, Allow both HTTPs and HTTP traffic and lastly allow full access to cloud API and click create.
2. SSH into the instance
The next step is to ssh into the instance to begin working on your instance. Click ssh and open open in window browser, this will open a terminal.
3. Install Coder
Head over to the terminal you opened in the step 2 above and run the the below command.
curl -fsSL https://coder.com/install.sh | sh
You will be in a position to see the following as the output. Follow the steps given to set up the coder.
Debian GNU/Linux 11 (bullseye)
Installing v0.12.7 of the amd64 deb package from GitHub.
+ mkdir -p ~/.cache/coder
+ curl -#fL -o ~/.cache/coder/coder_0.12.7_amd64.deb.incomplete -C - https://github.com/coder/coder/releases/download/v0.12.7/coder_0.12.7_linux_amd64.deb
######################################################################## 100.0%
+ mv ~/.cache/coder/coder_0.12.7_amd64.deb.incomplete ~/.cache/coder/coder_0.12.7_amd64.deb
+ sudo dpkg --force-confdef --force-confold -i ~/.cache/coder/coder_0.12.7_amd64.deb
Selecting previously unselected package coder.
(Reading database ... 54255 files and directories currently installed.)
Preparing to unpack .../coder/coder_0.12.7_amd64.deb ...
Unpacking coder (0.12.7-1) ...
Setting up coder (0.12.7-1) ...
deb package has been installed.
To run Coder as a system service:
# (Optional) Set up an external access URL
$ sudo vim /etc/coder.d/coder.env
# Use systemd to start Coder now and on reboot
$ sudo systemctl enable --now coder
# View the logs to ensure a successful start
$ journalctl -u coder.service -b
Or, just run the server directly:
$ coder server
4. Setting up Coder
Let’s follow the steps given when we run the coder script as shown in the output above. First edit coder.env
file. Use vim to open the file.
sudo vim /etc/coder.d/coder.env
Add CODER_TUNNEL=true
save and exit.
Use systemd to start Coder now and on reboot
sudo systemctl enable --now coder
You can view the logs to ensure a successful start of the Coder.
journalctl -u coder.service -b
Here is the output of the journalctl.
-- Journal begins at Tue 2022-11-15 11:12:48 UTC, ends at Tue 2022-11-15 11:38:04 UTC>
Nov 15 11:37:56 coder systemd[1]: Starting "Coder - Self-hosted developer workspaces >
Nov 15 11:37:56 coder coder[732]: Coder v0.12.7+49b340e - Remote development on your >
Nov 15 11:37:56 coder coder[732]: Using built-in PostgreSQL (/home/coder/.config/code>
Nov 15 11:38:00 coder coder[732]: Opening tunnel so workspaces can connect to your de>
Nov 15 11:38:00 coder coder[732]: Error picking closest dev tunnel: socket: permissio>
Nov 15 11:38:00 coder coder[732]: Defaulting to US East Pittsburgh
Nov 15 11:38:00 coder coder[732]: Using tunnel in US East Pittsburgh with latency 0s>
Nov 15 11:38:00 coder coder[732]: View the Web UI: https://fcca2ed0f46486478a4ce1aebc>
Nov 15 11:38:04 coder coder[732]: Get started by creating the first user (in a new te>
Nov 15 11:38:04 coder coder[732]: coder login https://fcca2ed0f46486478a4ce1aebc0a79>
Nov 15 11:38:04 coder coder[732]: ==> Logs will stream in below (press ctrl+c to grac>
Nov 15 11:38:04 coder systemd[1]: Started "Coder - Self-hosted developer workspaces o>
lines 1-13/13 (END)
We can now open the web user interface using the following given URL.
coder login https://fcca2ed0f46486478a4ce1aebc0a790b.pit-1.try.coder.app
When you have successfully created your account you are taken to workspaces. Here we can can our workspace with the use of a template.
Creating a workspace from the template
To begin creating a workspace, click on create from template.
Go to your terminal and run the following command to start build in templates
coder template init
This is what you will get from using the above command.
A template defines infrastructure as code to be provisioned for individual
developer workspaces. Select an example to be copied to the active directory:
Type to search
> Develop in an ECS-hosted container
Get started with Linux development on AWS ECS.
https://github.com/coder/coder/tree/main/examples/templates/aws-ecs-container
Develop in Linux on AWS EC2
Get started with Linux development on AWS EC2.
https://github.com/coder/coder/tree/main/examples/templates/aws-linux
Develop in Windows on AWS
Get started with Windows development on AWS.
https://github.com/coder/coder/tree/main/examples/templates/aws-windows
Develop in Linux on Azure
Get started with Linux development on Microsoft Azure.
https://github.com/coder/coder/tree/main/examples/templates/azure-linux
Develop in Linux on a Digital Ocean Droplet
Get started with Linux development on a Digital Ocean Droplet.
https://github.com/coder/coder/tree/main/examples/templates/do-linux
Develop in Docker
Run workspaces on a Docker host using registry images
https://github.com/coder/coder/tree/main/examples/templates/docker
Develop code-server in Docker
Run code-server in a Docker development environment
https://github.com/coder/coder/tree/main/examples/templates/docker-code-server
Choose the cloud provider you want to use. Here I will be using the GCP because I was running GCP.
When you click on GCP you will get the following output, cd into that directory and run coder templates create
to start creating the template.
A template defines infrastructure as code to be provisioned for individual
developer workspaces. Select an example to be copied to the active directory:
Extracting gcp-linux to ./gcp-linux...
Create your template by running:
cd ./gcp-linux && coder templates create
Examples provide a starting point and are expected to be edited! 🎨
If you get an error that you need to login use the following command to login.
Open the following in your browser:
#To login
$ coder login https://fcca2ed0f46486478a4ce1aebc0a790b.pit-1.try.coder.app
To get auth token
$ https://fcca2ed0f46486478a4ce1aebc0a790b.pit-1.try.coder.app/cli-auth
Paste your token here:
Welcome to Coder, sangkips! You're authenticated.
From here you will be in position to go into your workspace and start coding.