Zum Inhalt

Code Server role

Deploy Code Server (VS Code in the browser), a web-based development environment with Traefik reverse proxy integration.

Usage

Configure Code Server settings in your inventory:

1
2
3
4
5
6
7
8
# vars/main.yml
registry_username: your_registry_user
registry_password: your_registry_password
code_server_image_name: lscr.io/linuxserver/code-server
code_server_image_version: latest
code_server_hostname: code-server
code_server_sudo_password: your_secure_sudo_password
code_server_network_name: proxy

Include the role in your playbook:

1
2
3
4
# playbooks/proxmox/deploy_docker_services.yml
- hosts: docker_services
  roles:
    - role: code_server

The role provides these tags: - code-server-install - Deploy Code Server container - code-server-uninstall - Remove Code Server container

Docs

Deploy Code Server to your Docker host:

1
ansible-playbook -i inventory/hosts.yml playbooks/proxmox/deploy_docker_services.yml --tags code-server-install

Remove Code Server installation:

1
ansible-playbook -i inventory/hosts.yml playbooks/proxmox/deploy_docker_services.yml --tags code-server-uninstall

Configuration Details

The role deploys Code Server with: - LinuxServer.io Image: lscr.io/linuxserver/code-server - Traefik Integration: Automatic HTTPS via Traefik reverse proxy - Persistent Storage: Configuration and workspace data - User Permissions: PUID=1000, PGID=1000 - Timezone: Europe/Zurich - Sudo Access: Optional sudo with configurable password

Accessing Code Server

After deployment, Code Server is available at: - URL: https://code-server.rwcloud.ch - Port: 8443 (internal, accessed via Traefik)

Environment Variables

The container is configured with: - PUID=1000 / PGID=1000 - User/group IDs - TZ=Europe/Zurich - Timezone - SUDO_PASSWORD - Password for sudo within the container - PROXY_DOMAIN=code-server.rwcloud.ch - Domain for proper URL handling - DEFAULT_WORKSPACE=/config/workspace - Default project directory

Storage

One volume is created: - config - Contains VS Code configuration, extensions, and workspace files

Features

Code Server provides: - Full VS Code experience in the browser - Extension marketplace access - Git integration - Terminal access with sudo privileges - Multi-file editing - IntelliSense and debugging - Collaborative coding (via Live Share extension)

Workspace

Your code projects are stored in /config/workspace within the container. Mount additional volumes if you need access to specific host directories:

1
2
3
volumes:
  - config:/config
  - /host/projects:/config/workspace/projects

Security

  • Access is controlled via Traefik
  • Sudo requires the configured password
  • Consider adding authentication middleware in Traefik for additional security