diff --git a/2025-05-18_Code-Server.md b/2025-05-18_Code-Server.md new file mode 100644 index 0000000..6f9c75b --- /dev/null +++ b/2025-05-18_Code-Server.md @@ -0,0 +1,98 @@ +--- +date: 2025-05-18 +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 anyway. 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, at least as of around March 2025 when I last compared them. Things are moving *very* quickly in +this space, so it is hard to know how LLMs and IDE integrations compare from week to week. + +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 initially 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. This makes it a little easier to move deployments around since I just have to 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 configuration 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 ; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Ssl on; + proxy_pass http://coder:8080/; + } +} +``` + +## Initial Impressions +I wrote the bulk of this post about 2 months ago and I admittedly have not found myself using Code Server for +anything other than this blog project. I have been using Copilot in VSCode more regularly in my day-to-day, and its +lack of support in Code Server is probably a deal breaker for me. Even though I am unlikely to continue using +Code Server, I may check out Coder as a method for exposing a different IDE via web browser. + +## Future Plans +As mentioned, I might check out Coder as a more complete reproducible workspace +in lieu of Code Server. Alternatively, I might just run VSCode in a VM as a simpler solution, though I would miss +having things like easy clipboard integration. + +I have also started looking into [Neovim](https://neovim.io/) for code management and might work that into my setup. +I don't expect to get any kind of LLM code assistant functionality in `nvim`, but it would be an easy way to have a +single dev system that I can just connect to from whatever client I have available. I will probably dedicate my next +post here to documenting my `nvim` configuration (along with some updates to my +[previously-documented shell customizations](https://blog.mcknight.tech/2024/03/27/Shell-Customizations/)).