Skip to content

Instantly share code, notes, and snippets.

@razhangwei
Created February 17, 2025 23:47
Show Gist options
  • Save razhangwei/1c8a5e6c7292e92109c163005196c82e to your computer and use it in GitHub Desktop.
Save razhangwei/1c8a5e6c7292e92109c163005196c82e to your computer and use it in GitHub Desktop.
#OMV #vscode code-server
  1. Create Dockerfile via UI and build.
FROM codercom/code-server:latest

USER root

# Install system dependencies
RUN apt-get update && apt-get install -y \
    python3-pip \
    python3-venv \
    pipx \
    git \
    curl \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Switch to non-root user
USER coder

# Install pipx tools globally
RUN pipx install aider-chat \
    && pipx install poetry \
    && pipx install pre-commit

# Add pipx binaries to PATH
ENV PATH="${PATH}:/home/coder/.local/bin"

# Create virtual environment directory
RUN mkdir -p /home/coder/.venvs

# Add custom VS Code extensions
RUN code-server --install-extension ms-python.python \
    && code-server --install-extension ms-toolsai.jupyter 

# Create workspace directory
RUN mkdir -p /home/coder/workspace

WORKDIR /home/coder/workspace
  1. Add the following docker file docker-compose file
services:
  code-server:
    image: dev-environment:latest
    container_name: dev-environment
    environment:
      - PUID=$PUID
      - PGID=$PGID
      - TZ=$TZ
      - PASSWORD=${PASSWORD}
    volumes:
      - ./config:/home/coder/.config
      - ./workspace:/home/coder/workspace
      - ./.venvs:/home/coder/.venvs
      - ./git-credentials:/home/coder/.git-credentials
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "8443:8080"
    restart: unless-stopped
    security_opt:
      - seccomp:unconfined
    networks:
      - dev-network

networks: # better network isolation and container communication
  dev-network:
    name: dev-network
    driver: bridge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment