Skip to content

Attacler/open-code-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open Code Server

A fully-featured VS Code running in a container, pre-configured with Node.js, Python, Rust, and automatic GitHub repository integration.

Features

  • VS Code in browser - Full VS Code experience accessible via web browser
  • Pre-installed tools - Node.js 20, Python 3, pip, Rust toolchain, Cargo
  • GitHub integration - Automatic git configuration and repository cloning
  • Seamless git operations - Built-in GitHub authentication for push/pull/fetch
  • Persistent workspace - Your code and settings persist across container restarts

Quick Start

1. Build the Image

docker build -t open-code-server .

2. Access Code Server

Open your browser and navigate to: https://localhost:8443

Default password: password

Environment Variables

Base Code Server Variables

Variable Description Default
PUID User ID for file permissions 1000
PGID Group ID for file permissions 1000
TZ Timezone Etc/UTC
PASSWORD Access password for code-server password
DEFAULT_WORKSPACE Default workspace directory /config/workspace

GitHub Integration Variables

Variable Description Example
GITHUB_TOKEN Personal access token for authentication ghp_xxxxxxxxxxxx
GITHUB_REPOSITORY Repository to clone (format: username/repo) myuser/myproject
GIT_USERNAME Git author name John Doe
GIT_EMAIL Git author email john@example.com

How It Works

Container Startup

When the container starts:

  1. Git Configuration - Sets global git username and email
  2. Repository Clone - If /config/workspace is empty, clones the specified GitHub repository
  3. Authentication - Configures git remote with embedded token for authenticated operations
  4. Permission Setup - Ensures correct ownership for the workspace directory
  5. Code Server Launch - Starts the code-server application

Git Operations

The container automatically handles GitHub authentication by embedding your access token in the git remote URL. This enables:

  • git push - Push changes to your repository
  • git pull - Pull updates from the repository
  • git fetch - Fetch remote changes
  • All other git operations requiring authentication

Creating a GitHub Token

  1. Go to GitHub Settings → Developer settings → Personal access tokens
  2. Click "Generate new token" (classic)
  3. Select scopes: repo (for full repository access)
  4. Generate and copy the token
  5. Set it as GITHUB_TOKEN environment variable

File Structure

.
├── Dockerfile              # Container image definition
├── docker-entrypoint.sh    # Startup script for git setup
├── start-container.sh      # Docker run command template
├── config/                 # Persistent data (workspace, settings)
│   └── workspace/          # Your code repository
└── README.md              # This file

Troubleshooting

Permission Denied Errors

If you encounter permission issues with git operations:

# Stop the container
docker stop code-server

# Fix workspace permissions
sudo chown -R 1000:1000 ./config/workspace

# Restart the container
docker start code-server

Git Push Fails

Ensure your GitHub token has the correct permissions:

  • Token must have repo scope
  • Token must be valid (not expired)
  • Repository must exist and be accessible to your account

Workspace Not Cloning

Check that:

  • GITHUB_TOKEN is set correctly
  • GITHUB_REPOSITORY format is username/repo
  • /config/workspace directory is empty
  • Network connectivity to GitHub is available

Docker Compose

A docker-compose.yml file is provided. Edit it with your GitHub credentials, then run:

docker-compose up -d

Or with Docker Compose:

docker compose up -d

Pre-installed Tools

  • VS Code - Latest code-server
  • Node.js - Version 20.x via NodeSource
  • Python - Python 3 with pip
  • Rust - Latest stable toolchain via rustup
  • Git - Pre-installed and configured
  • OpenCode CLI - Additional development tools

License

This project builds upon linuxserver/code-server and VS Code.

Support

For issues related to:

About

One Docker container that contains Opencode, code-server.

Resources

Stars

Watchers

Forks

Contributors