Document Code Server

This commit is contained in:
Daniel McKnight 2025-03-15 09:42:06 -07:00
parent e981784c48
commit 7d9b4aded3

93
2025-03-13_Code-Server.md Normal file
View file

@ -0,0 +1,93 @@
---
date: 2025-03-13
title: Code Server
tags:
- homelab
- development
- software
- code-assistant
---
I recently started using [Forgejo](https://forgejo.org/) for managing my personal projects (including this blog content).
Prior to this, I was using self-hosted [GitLab](https://about.gitlab.com/); maybe I'll write a full post about this
in the future, but basically I made the change because GitLab in Docker was a real memory hog and I much prefer
open source solutions where available. One thing I missed from GitLab (and GitHub) is the built-in web IDE for
making changes without having to clone the project locally. I found [Coder](https://coder.com/docs/code-server)
which provides a containerized VSCode PWA that I plan to use as an alternative to GitHub Codespaces and GitLab
workspaces.
## What is Code Server
Code Server is an open source container distribution of VSCodium. VSCodium is the open source release of VSCode (think
Chromium and Google Chrome). I personally have more experience with PyCharm and other JetBrains IDEs, but VSCode
is another popular option and I've been making the transition at work from PyCharm to VSCode after comparing the
LLM integration between them. Long story short, VSCode is miles ahead of JetBrains IDEs for code writing and
LLM context management as of sometime last week when I tested them both.
I haven't fully evaluated the differences between VSCode and Code Server yet, but in the context of a replacement for
what I had with GitLab and GitHub I am satisfied with what I see in Code Server.
## Deployment
Deployment is as simple as starting a Docker container. In addition to the documented setup process, I also mounted
a directory with my SSH configuration and keys so that I can easily connect to GitHub and my private Forgejo via SSH.
I configured nginx ingress (for access from my LAN only). For most deployments, its probably easier to just use IP
addresses but I like using nginx so that its a little easier to move deployments around and just update Nginx to point at
the appropriate IP address. I've included my site config below in case anyone reading this wants to achieve something
similar. I don't know that this is optimal, but it is working.
```
server {
listen 80;
listen 443 ssl;
server_name code.*;
include /config/nginx/ssl.conf;
add_header Front-End-Https on;
location / {
include /config/nginx/local_only.conf;
include /config/nginx/resolver.conf;
# Advanced Proxy Config
send_timeout 5m;
proxy_read_timeout 240;
proxy_send_timeout 240;
proxy_connect_timeout 240;
# Basic Proxy Config
proxy_set_header Host $host:$server_port;
proxy_set_header X-Client-IP $http_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect http:// $scheme://;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
proxy_cache_bypass $cookie_session;
proxy_no_cache $cookie_session;
proxy_buffers 32 4k;
proxy_max_temp_file_size 2048m;
proxy_set_header X-Forwarded-Host code.mcknight.tech;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_pass http://coder:8080/;
}
}
```
## Future Plans
I still have some work to do before I decide whether or not Code Server can be my regular IDE, but so far it is a
solid option for when I'm on my laptop doing things like writing this post. Compared to a VM, I appreciate being
able to just copy/paste from my local clipboard. I might check out Coder as a more complete reproducible workspace
in lieu of Code Server, or I might give in and go with VSCode in a VM so that I get Copilot integration.
On a related node, I did try Cursor at work and was impressed with the LLM integration which does seem to outdo
what VSCode offers. I decided against adopting it for regular use since you do have to commit to a monthly
subscription and I'm not a big fan of the UI changes they applied on top of VSCode. My hope is that eventually
VSCode or some fork of it will enable local LLM integration, but then I would also want an open source LLM that
performs comparably to GPT-4o and Claude 3.7.