TurboRepo Project with Next.js, Reverse Proxy using traefik and Dockerode (aws-sdk for aws ecs-ec2) , and node-pty Client-Specific Containers using Socket
This project uses TurboRepo to manage a multi-repository setup, including:
- A Next.js application.
- A reverse proxy Docker container.
- Client-specific Docker containers for handling individual connections via WebSocket.
- xterm.js for terminal emulation.
- Monaco Editor for the file explorer in the app.
.
├── /apps
│ └── client # Next.js client application
├── /packages
│ └── docker
│ ├── reverse-proxy # Docker image for reverse proxy setup
│ └── client-docker # Docker container setup for each client
└── turbo.json # TurboRepo configuration
Reverse Proxy: Manages client connections dynamically, routing requests to user-specific containers. Client-Specific Containers: Each user gets a dedicated Docker container, ensuring isolated terminal sessions. WebSocket Support: For real-time communication between the Next.js app and Docker containers. Terminal Interface: Powered by xterm.js. Monaco Editor: A powerful code editor for exploring and modifying files inside the containers.
- Docker installed on your machine.
- pnpm as the package manager.
- TurboRepo configured (comes with pnpm).
bash
git clone <repository-url>
cd <project-directory>
bash
pnpm install
Start Docker: Ensure Docker is running on your machine.
bash
pnpm build-server # Build the websocket conatiner node-pty
pnpm build-proxy # Build the reverse proxy Docker image
bash
pnpm dev # Start the Next.js development server
bash
pnpm start-proxy # Start the reverse proxy Docker container
- Open the Next.js app in your browser.
- On login or interaction, a client-specific Docker container is spun up.
- The reverse proxy will forward the request to the correct container (e.g., userid.localhost).
- Use the xterm.js terminal for interacting with the container and the Monaco Editor for exploring files.
Docker Issues: Ensure Docker is running and containers are not blocked by the firewall. WebSocket Connections: Verify that the reverse proxy correctly forwards WebSocket traffic. pnpm Issues: If commands fail, try running:
bash
pnpm clean
pnpm install
Feel free to submit issues or pull requests to improve this project. License
This project is licensed under the MIT License. Contact
