Deploy y-websocket Server Using Docker
There are multiple y-websocket compatible backends for y-websocket.
This guide will show you how to deploy a y-websocket server using Docker.
By using either @y/websocket-server
or hocuspocus
, you can set up a collaborative editing backend tailored to your needs.
@y/websocket-server
The @y/websocket-server
is an official implementation of a y-websocket server. It is lightweight and easy to set up.
Official Documentation
https://github.com/yjs/y-websocket-server.
Method 1: Deploy Using Docker
Below is a sample Dockerfile
to deploy the @y/websocket-server
:
1 |
|
To build and run the Docker container:
- Save the above
Dockerfile
in a directory. - Build the Docker image:
1
docker build -t y-websocket-server .
- Run the container:
1
docker run -p 1234:1234 y-websocket-server
Your y-websocket server will now be accessible on port 1234
.
Method 2: Direct Use
If you prefer not to use Docker, you can install and run the server directly on your local machine:
1 |
|
This will start the server on the default port 1234
.
hocuspocus
hocuspocus
is another y-websocket-compatible backend.
It provides additional features like authentication, awareness updates, and persistence.
Official Documentation
You can find the official documentation here: hocuspocus GitHub Repository.
Method 1: Deploy Using Docker
Below is a sample Dockerfile
to deploy hocuspocus
:
1 |
|
To build and run the Docker container:
- Save the above
Dockerfile
in a directory. - Build the Docker image:
1
docker build -t hocuspocus-server .
- Run the container:
1
docker run -p 1234:1234 hocuspocus-server
Your hocuspocus
server will now be accessible on port 1234
.
Method 2: Direct Use
If you prefer not to use Docker, you can install and run the server directly on your local machine:
1 |
|
This will start the server on the default port 1234
.