Skip to content

Commit 1e24e3d

Browse files
authored
Update etherpad setup documentation (#50)
1 parent 00ae7fe commit 1e24e3d

File tree

2 files changed

+108
-85
lines changed

2 files changed

+108
-85
lines changed

docs/services/etherpad/How it works.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- ETHERPAD__URI - Uri of etherpad api for all calls like create, delete etc. Used as base path for api client in nest and feathers backend.
1313

1414
- ETHERPAD__PAD_URI - URI to etherpad client api. Used in backend in collaborative text editor and lesson to build return url. Used in legacy client to build url.
15-
- ETHERPAD_OLD_PAD_URI - Used in feathers backend to restrict access to old etherpad urls to lesson context. Only defined in default.schema.json and not in dof-app-deploy
15+
- ETHERPAD__OLD_PAD_URI - Used in feathers backend to restrict access to old etherpad urls to lesson context. Only defined in default.schema.json and not in dof-app-deploy
1616
- ETHERPAD__PAD_PATH - Path to etherpad client api. Used in legacy client to set path on cookie.
1717

1818
- ETHERPAD__NEW_DOMAIN - Etherpad Domain. Used in legacy client to validate url

docs/services/etherpad/Local setup.md

Lines changed: 107 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ Create a directory called sc-etherpad and then enter it, in Unix-like systems y
99

1010
`mkdir sc-etherpad && cd sc-etherpad`
1111

12-
2. Create a new file called APIKEY.txt in it, with the following content:
12+
2. Create a new file called `APIKEY.txt` in it, with the following content:
1313

1414
`381d67e6347d235ac9446da3ea10a82efd6f8ae09fa2e90efeda80f82feeb4fd`
1515

1616
We'll use this file to set a fixed Etherpad's API key on the Etherpad server's start.
1717

18-
3. Create also a file called settings.env with the following content:
18+
3. Create also a file called `settings.env` with the following content:
1919

2020
```
2121
REQUIRE_SESSION="true"
@@ -24,99 +24,122 @@ Create a directory called sc-etherpad and then enter it, in Unix-like systems y
2424
DEFAULT_PAD_TEXT="Schreib etwas!\n\nDieses Etherpad wird synchronisiert, während du tippst, so dass alle Betrachter jederzeit den selben Text sehen. So könnt ihr auf einfache Weise gemeinsam an Dokumenten arbeiten."
2525
DB_TYPE=mongodb
2626
DB_URL=mongodb://host.docker.internal:27017/etherpad
27+
AUTHENTICATION_METHOD=apikey
2728
```
2829
We'll use this file to provide all the needed environment variables to the Etherpad's server.
2930
30-
Please note the last line, that contains the MongoDB connection string:
31+
Please note the line that contains the MongoDB connection string:
3132
3233
`DB_URL=mongodb://host.docker.internal:27017/etherpad`
3334
34-
Here we're using the host.docker.internal hostname which should make it possible for the Etherpad's container to connect to the host's local network and should work out of the box e.g. on macOS. But please modify it accordingly to your needs and your Docker's network configuration. An alternative configuaration would be to use `DB_URL=mongodb://localhost:27017/etherpad` and than add `--network="host"` to the following docker run command.
35+
Here we're using the `host.docker.internal` hostname which should make it possible for the Etherpad's container to connect to the host's local network and should work out of the box e.g. on macOS. On WSL2 it might not work out of the box and need some extra work, see e.g. this [stackoverflow thread](https://stackoverflow.com/questions/63898430/how-can-i-access-a-service-running-on-wsl2-from-inside-a-docker-container).
36+
37+
An alternative configuaration would be to use `DB_URL=mongodb://localhost:27017/etherpad` and then add `--network="host"` to the following docker run command. `--network="host"` removes the port mapping though. You can change the port Etherpad is listening on by adding `PORT=9002` (or the port number you need) to settings.env.
3538
3639
4. Next, start the Etherpad's container:
3740
```
3841
docker run -d \
39-
-p 9001:9001 \
42+
-p 9002:9001 \
4043
--env-file ./settings.env \
4144
-v ./APIKEY.txt:/opt/etherpad-lite/APIKEY.txt \
4245
--name sc-etherpad \
43-
docker.io/etherpad/etherpad:2.0.0
46+
docker.io/etherpad/etherpad:2.2.7
4447
```
45-
Please note we're using the docker.io/etherpad/etherpad:2.0.0 image in the command above which might be not the one that is being used anytime in the future when you read this article. To make sure you're using the current version (the one that is currently being used in the SchulCloud platform), please refer to the https://github.com/hpi-schul-cloud/dof_app_deploy/blob/main/ansible/group_vars/infra/dof_etherpad.yml file.
46-
47-
Now we should have the Etherpad service running locally on port 9001, we can verify it's working properly e.g. by fetching the current Etherpad's API version:
48-
49-
```
50-
~ curl -v http://127.0.0.1:9001/api
51-
* Trying 127.0.0.1:9001...
52-
* Connected to 127.0.0.1 (127.0.0.1) port 9001
53-
> GET /api HTTP/1.1
54-
> Host: 127.0.0.1:9001
55-
> User-Agent: curl/8.4.0
56-
> Accept: */*
57-
>
58-
< HTTP/1.1 200 OK
59-
< X-Powered-By: Express
60-
< X-UA-Compatible: IE=Edge,chrome=1
61-
< Referrer-Policy: same-origin
62-
< Content-Type: application/json; charset=utf-8
63-
< Content-Length: 26
64-
< ETag: W/"1a-2HmNLqF3wPt+KQRlEmGwH4O+xu4"
65-
< Date: Fri, 29 Mar 2024 13:27:00 GMT
66-
< Connection: keep-alive
67-
< Keep-Alive: timeout=5
68-
<
69-
* Connection #0 to host 127.0.0.1 left intact
70-
{"currentVersion":"1.3.0"}
71-
```
72-
73-
We can also verify that the API key has been set successfully, let's use the example API call from the Etherpad's documentation ( https://etherpad.org/doc/v2.0.0/#_example_1 ):
74-
75-
```
76-
~ curl -v http://127.0.0.1:9001/api/1/createAuthorIfNotExistsFor\?apikey\=381d67e6347d235ac9446da3ea10a82efd6f8ae09fa2e90efeda80f82feeb4fd\&name\=Michael\&authorMapper\=7
77-
* Trying 127.0.0.1:9001...
78-
* Connected to 127.0.0.1 (127.0.0.1) port 9001
79-
> GET /api/1/createAuthorIfNotExistsFor?apikey=381d67e6347d235ac9446da3ea10a82efd6f8ae09fa2e90efeda80f82feeb4fd&name=Michael&authorMapper=7 HTTP/1.1
80-
> Host: 127.0.0.1:9001
81-
> User-Agent: curl/8.4.0
82-
> Accept: */*
83-
>
84-
< HTTP/1.1 200 OK
85-
< X-Powered-By: Express
86-
< X-UA-Compatible: IE=Edge,chrome=1
87-
< Referrer-Policy: same-origin
88-
< Content-Type: application/json; charset=utf-8
89-
< Content-Length: 66
90-
< ETag: W/"42-bg92QA1xRFO6QmkNRbNXhfsFBUM"
91-
< Date: Fri, 29 Mar 2024 13:40:05 GMT
92-
< Connection: keep-alive
93-
< Keep-Alive: timeout=5
94-
<
95-
* Connection #0 to host 127.0.0.1 left intact
96-
{"code":0,"message":"ok","data":{"authorID":"a.7BgkAuzbHXR1G8Cv"}}
97-
```
98-
99-
In case of an unsuccessful result (e.g. improperly set or invalid API key) we would receive the following response:
100-
```
101-
~ curl -v http://127.0.0.1:9001/api/1/createAuthorIfNotExistsFor\?apikey\=secret\&name\=Michael\&authorMapper\=7
102-
* Trying 127.0.0.1:9001...
103-
* Connected to 127.0.0.1 (127.0.0.1) port 9001
104-
> GET /api/1/createAuthorIfNotExistsFor?apikey=secret&name=Michael&authorMapper=7 HTTP/1.1
105-
> Host: 127.0.0.1:9001
106-
> User-Agent: curl/8.4.0
107-
> Accept: */*
108-
>
109-
< HTTP/1.1 401 Unauthorized
110-
< X-Powered-By: Express
111-
< X-UA-Compatible: IE=Edge,chrome=1
112-
< Referrer-Policy: same-origin
113-
< Content-Type: application/json; charset=utf-8
114-
< Content-Length: 54
115-
< ETag: W/"36-dbJd0O+vdNi3zPpwRXE+1EGLTho"
116-
< Date: Fri, 29 Mar 2024 13:39:44 GMT
117-
< Connection: keep-alive
118-
< Keep-Alive: timeout=5
119-
<
120-
* Connection #0 to host 127.0.0.1 left intact
121-
{"code":4,"message":"no or wrong API Key","data":null}
122-
```
48+
We're using the docker.io/etherpad/etherpad:2.2.7 image in the command above. To make sure you're using the version that is currently used in the SchulCloud platform, please refer to https://github.com/hpi-schul-cloud/dof_app_deploy/blob/main/ansible/roles/dof_etherpad/defaults/main.yml.
49+
50+
The bound port on the host (here 9002) is arbitrary, though port 9001 is used by MinIO in our default project setup and thus we use a different one here.
51+
52+
5. Now we should have the Etherpad service running locally on port 9002, we can verify it's working properly e.g. by fetching the current Etherpad's API version:
53+
54+
```
55+
~ curl -v http://127.0.0.1:9002/api
56+
* Trying 127.0.0.1:9002...
57+
* Connected to 127.0.0.1 (127.0.0.1) port 9002
58+
> GET /api HTTP/1.1
59+
> Host: 127.0.0.1:9002
60+
> User-Agent: curl/8.4.0
61+
> Accept: */*
62+
>
63+
< HTTP/1.1 200 OK
64+
< X-Powered-By: Express
65+
< X-UA-Compatible: IE=Edge,chrome=1
66+
< Referrer-Policy: same-origin
67+
< Content-Type: application/json; charset=utf-8
68+
< Content-Length: 26
69+
< ETag: W/"1a-2HmNLqF3wPt+KQRlEmGwH4O+xu4"
70+
< Date: Fri, 29 Mar 2024 13:27:00 GMT
71+
< Connection: keep-alive
72+
< Keep-Alive: timeout=5
73+
<
74+
* Connection #0 to host 127.0.0.1 left intact
75+
{"currentVersion":"1.3.0"}
76+
```
77+
78+
We can also verify that the API key has been set successfully, let's use the example API call from the Etherpad's documentation ( https://etherpad.org/doc/v2.2.7/#_example_1 ):
79+
80+
```
81+
~ curl -v http://127.0.0.1:9002/api/1/createAuthorIfNotExistsFor\?apikey\=381d67e6347d235ac9446da3ea10a82efd6f8ae09fa2e90efeda80f82feeb4fd\&name\=Michael\&authorMapper\=7
82+
* Trying 127.0.0.1:9002...
83+
* Connected to 127.0.0.1 (127.0.0.1) port 9002
84+
> GET /api/1/createAuthorIfNotExistsFor?apikey=381d67e6347d235ac9446da3ea10a82efd6f8ae09fa2e90efeda80f82feeb4fd&name=Michael&authorMapper=7 HTTP/1.1
85+
> Host: 127.0.0.1:9002
86+
> User-Agent: curl/8.4.0
87+
> Accept: */*
88+
>
89+
< HTTP/1.1 200 OK
90+
< X-Powered-By: Express
91+
< X-UA-Compatible: IE=Edge,chrome=1
92+
< Referrer-Policy: same-origin
93+
< Content-Type: application/json; charset=utf-8
94+
< Content-Length: 66
95+
< ETag: W/"42-bg92QA1xRFO6QmkNRbNXhfsFBUM"
96+
< Date: Fri, 29 Mar 2024 13:40:05 GMT
97+
< Connection: keep-alive
98+
< Keep-Alive: timeout=5
99+
<
100+
* Connection #0 to host 127.0.0.1 left intact
101+
{"code":0,"message":"ok","data":{"authorID":"a.7BgkAuzbHXR1G8Cv"}}
102+
```
103+
104+
In case of an unsuccessful result (e.g. improperly set or invalid API key) we would receive the following response:
105+
```
106+
~ curl -v http://127.0.0.1:9002/api/1/createAuthorIfNotExistsFor\?apikey\=secret\&name\=Michael\&authorMapper\=7
107+
* Trying 127.0.0.1:9002...
108+
* Connected to 127.0.0.1 (127.0.0.1) port 9002
109+
> GET /api/1/createAuthorIfNotExistsFor?apikey=secret&name=Michael&authorMapper=7 HTTP/1.1
110+
> Host: 127.0.0.1:9002
111+
> User-Agent: curl/8.4.0
112+
> Accept: */*
113+
>
114+
< HTTP/1.1 401 Unauthorized
115+
< X-Powered-By: Express
116+
< X-UA-Compatible: IE=Edge,chrome=1
117+
< Referrer-Policy: same-origin
118+
< Content-Type: application/json; charset=utf-8
119+
< Content-Length: 54
120+
< ETag: W/"36-dbJd0O+vdNi3zPpwRXE+1EGLTho"
121+
< Date: Fri, 29 Mar 2024 13:39:44 GMT
122+
< Connection: keep-alive
123+
< Keep-Alive: timeout=5
124+
<
125+
* Connection #0 to host 127.0.0.1 left intact
126+
{"code":4,"message":"no or wrong API Key","data":null}
127+
```
128+
129+
6. Set the following config values in the server:
130+
| Key | Value |
131+
| --- | --- |
132+
| ETHERPAD__API_KEY | 381d67e6347d235ac9446da3ea10a82efd6f8ae09fa2e90efeda80f82feeb4fd |
133+
| ETHERPAD__URI | http://localhost:9002/api/1 |
134+
| ETHERPAD__PAD_URI | http://localhost:9002/p |
135+
136+
Set the following config values in the client:
137+
| Key | Value |
138+
| --- | --- |
139+
| ETHERPAD__PAD_URI | http://localhost:9002/p |
140+
| ETHERPAD__PAD_PATH | /p |
141+
| ETHERPAD__NEW_DOMAIN | localhost |
142+
143+
For the other config values the defaults in `default.schema.json` should work.
144+
145+
7. Now you should be able to create and use Etherpads in boards and topics.

0 commit comments

Comments
 (0)