You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+44-34
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,42 @@
1
-
# Instructions to setup the lab using DOCKER container (2023-04-19)
1
+
# Instructions to set up the lab using DOCKER container (2023-04-19)
2
2
3
3
This text is for _developer_ and _maintainer_ of the openroberta lab, _not_ if you want to run a local server. Running a local server is described in our
4
4
[wiki on GitHub](https://github.com/OpenRoberta/openroberta-lab/wiki/Instructions-to-run-a-openroberta-lab-server-using-DOCKER). This text describes the
5
5
docker-related scripts, which are used for a large installation (as our prod and test servers are),
6
6
7
-
- to setup a docker network,
7
+
- to set up a docker network,
8
8
- create docker images for a data base server and lab server and
9
9
- run docker container of the OpenRoberta lab.
10
10
11
11
On every Linux-based machine it should be easy to run our setup. Commands are shown as bash commands. Windows 10 should work too, if you are careful with
12
-
pathes. Btw: if you install git for Windows, you get a nice bash running in Windows.
12
+
path's. Btw: if you install git for Windows, you get a nice bash running in Windows.
13
13
14
14
`docker` must be installed. `java` version 11 (eleven!) must be installed. `mvn` must be installed.
15
+
Note: docker stores its data in the directory `/var/lib/docker`. Sometimes the underlying filesystem (usually `/var/`) is too small for this data.
16
+
If you have a large filesystem, you can move the data by executing:
17
+
```bash
18
+
# move docker files from /var/lib/docker to /data/lib/docker
19
+
service docker stop
20
+
mkdir -p /data/lib/
21
+
mv /var/lib/docker/ /data/lib/docker/
22
+
ln -s /data/lib/docker/ /var/lib/docker
23
+
service docker start
24
+
```
15
25
16
26
## Create an instance of our docker installation
17
27
18
28
- run `git clone https://github.com/OpenRoberta/docker`.
19
29
20
-
-**make the foundationn** by calling `./ora.sh new-docker-setup <BASEDIR>`. The `<BASEDIR>` must _not_ exist.
30
+
-**make the foundation** by calling `./ora.sh new-docker-setup <BASEDIR>`. The `<BASEDIR>` must _not_ exist.
21
31
- move the docker git repository to `<BASEDIR>/git`. You may need it later to update the docker installation.
22
32
- cd to `<BASEDIR>/git` and call `git clone https://github.com/OpenRoberta/openroberta-lab`. This repository is needed later when docker images are generated.
23
33
- cd to `<BASEDIR>/git/openroberta-lab` and call `mvn clean install -DskipTests`. This must succeed. The generated resources are needed if you want
24
34
to create empty databases later.
25
35
26
36
-**create the servers you need** by calling `./ora.sh new-server-in-docker-setup <BASEDIR> <SERVER>`. Note, that `test, dev, dev1...dev9` are the
27
37
only names accepted as server names. It is easy to add or remove server later.
28
-
- edit the properpy file `decl.sh` for each server. The data to be filled in should be obvious.
29
-
- for each server a data base of its own is needed. Double check that the data bases are in `<BASEDIR>/db`. An empty database can be created
38
+
- edit the property file `decl.sh` for each server. The data to be filled in should be obvious.
39
+
- for each server a database of its own is needed. Double check that the databases are in `<BASEDIR>/db`. An empty database can be created
30
40
- if you cd to `<BASEDIR>/git/openroberta-lab` and
- create a new docker bridge network (`RUN gen-net`). The name of the network is defined in the global `decl.sh`.
42
52
- generate a database server image and start the database container (`RUN gen-dbc` and `RUN start-dbc`). Check the result with `docker ps`. Inspect the log file
43
53
in `BASEDIR/db/dbAdmin/`
44
-
- deploy the server ((`RUN deploy SERVER`). Check the result with `docker ps`. Inspect the log file in `BASEDIR/server/SERVER/admin/logging/...`
54
+
- deploy the server (`RUN deploy SERVER`). Check the result with `docker ps`. Inspect the log file in `BASEDIR/server/SERVER/admin/logging/...`
45
55
46
56
Looks more complicated as it is :-). I tried to make all scripts as robust as possible. Please mail any problems, improvements, ideas to reinhard.budde at
47
57
iais.fraunhofer.de
@@ -52,20 +62,20 @@ iais.fraunhofer.de
52
62
53
63
# (re-)create the base image (done from time to time)
54
64
55
-
The docker "base" image is used as basis for the images, that run a version of the openrobrta lab. The version number of thee base image is used in
65
+
The docker "base" image is used as basis for the images, that run a version of the openroberta lab. The version number of the base image is used in
56
66
the `decl.sh` of each server. It contains all software needed by the lab to create binaries for all the robots, i.e.
57
67
58
-
- the crosscompiler binaries itself. They are installed by calling `apt`, `wget`, ... .
59
-
- header, libraries, scripts, ..., to be used together with the crosscompiler.
68
+
- the cross-compiler binaries itself. They are installed by calling `apt`, `wget`, ... .
69
+
- header, libraries, scripts, ..., to be used together with the cross-compiler.
60
70
61
-
This image is build in two steps. Because the crosscompiler binaries dont't change often, an image `openroberta/ccbin-${ARCH}` is build first. From this image
71
+
This image is build in two steps. Because the cross-compiler binaries don't change often, an image `openroberta/ccbin-${ARCH}` is build first. From this image
62
72
the `openroberta/base-${ARCH}` image is derived. This occurs more often. Both images have an independent version numbering.
63
73
64
-
1. The image with crosscompiler binaries is very seldom build, because the crosscompiler binaries are stable. It is available at dockerhub.
74
+
1. The image with cross-compiler binaries is very seldom build, because the cross-compiler binaries are stable. It is available at dockerhub.
65
75
Name: `openroberta/ccbin-x64:<number>>`. The current version (19.4.2023) is _2_. The image is created using the shell
66
76
command `RUN gen_ccbin <arch> <ccbin-version>`. The last build was `RUN gen_ccbin x64 2`.
67
77
68
-
2. The image with crosscompiler resources is more often build, because our add-ons, e.g. header files, libs, ... change more frequently. The image is available
78
+
2. The image with cross-compiler resources is more often build, because our add-ons, e.g. header files, libs, ... change more frequently. The image is available
69
79
at dockerhub. Name: `openroberta/base-x64:<number>>`. The current version (19.4.2023) is _35_. To create it, you need a clone of our GitHub
70
80
repository `ora-cc-rsc`, whose path is set in the command below (`CC_RESOURCES`). It contains the resources to be copied into the Docker image. \_Make sure,
71
81
that the repository `ora-cc-rsc` is clean. Uncommitted data will be lost. The Docker image is created using the shell
@@ -83,14 +93,14 @@ data from that tag is the data stored in the base image.
83
93
# Operating Instructions for the Test and Prod Server
84
94
85
95
For developing the lab, we use a test server, which serves many different instances of the openroberta lab server. Our prod server runs the prod version of the
86
-
openroberta lab server. They are setup in the same way. The following text describes the test server setup (the prod setup is the same, but uses a server
96
+
openroberta lab server. They are set up in the same way. The following text describes the test server setup (the prod setup is the same, but uses a server
87
97
named `master` only).
88
98
89
99
## Directory structure
90
100
91
101
The template for our framework is contained in directory `Docker/openroberta`. It contains the directories
92
102
93
-
- conf - contains an example of an nginx and an apache2 configuration and directories used to generate docker images for the db and the lab server
103
+
- conf - contains an example of a nginx and an apache2 configuration and directories used to generate docker images for the db and the lab server
94
104
95
105
- scripts - contains shell scripts to administrate the framework. The main script is `run.sh`. Call it without parameters to get help. the directory `helper`
96
106
contains scripts, that are sourced from `run.sh` and do the "real" work.
@@ -139,12 +149,12 @@ docker ps # the container for 'dev4' should be running
139
149
## Web server software
140
150
141
151
We need a running web server to distribute requests to the different openroberta lab servers. This is done with web server software. Apache and nginx are most
142
-
popular. Inside the server docker container the port 1999 is used. When a server container is started, this port is mapped to a accessible port on the host
143
-
machine (this maybe 1999 again, or 1998, ... or any other port. For instance, on the prod server
152
+
popular. Inside the server docker container the port 1999 is used. When a server container is started, this port is mapped to an accessible port on the host
153
+
machine (this maybe 1999 again, or 1998, ... or any other port). For instance, on the prod server
144
154
145
155
-`container:1999` is mapped to
146
156
-`host:8080` and
147
-
- the web server maps that to the offical addresses `lab.open-roberta.org.443` and `lab.open-roberta.org.80`
157
+
- the web server maps that to the official addresses `lab.open-roberta.org.443` and `lab.open-roberta.org.80`
148
158
149
159
The nginx configuration examples are in the directory `z-nginx`. The configuration directory on the host machine is `/etc/nginx/`. In the example
150
160
file `nginx.conf` see the ssl-, -server and include-section in the example file for the global configuration. The example file `lab.open-roberta`
@@ -157,7 +167,7 @@ Actually we are using nginx. Apache would do as well.
157
167
All data is stored relative to a base directory `$BASE_DIR` (your choice, we use `/data/openroberta-lab`). Abbreviations:
158
168
159
169
```bash
160
-
BASE_DIR=/data/openroberta-lab # the directory, in which the main configuration file 'decl.sh' is foundd
170
+
BASE_DIR=/data/openroberta-lab # the directory, in which the main configuration file 'decl.sh' is found
161
171
CONF_DIR=$BASE_DIR/conf
162
172
SCRIPT_DIR=$BASE_DIR/scripts
163
173
SERVER_DIR=$BASE_DIR/server
@@ -219,7 +229,7 @@ The database server is listening to the port `$DATABASE_SERVER_PORT` as defined
219
229
220
230
The shell script `$SCRIPT_DIR/run.sh` has commands, that are used for operating purposes.
221
231
222
-
-`auto-deploy`: usually called from cron. It takes server names from the variable `AUTODEPLOY` from the glocal`decl.sh` and re-deploys each server, if the git
232
+
-`auto-deploy`: usually called from cron. It takes server names from the variable `AUTODEPLOY` from the global`decl.sh` and re-deploys each server, if the git
223
233
repository connected to this server has got new commits. Use `crontab -e` to add the following line to the crontab to look for commits every 5 minutes:
224
234
225
235
```bash
@@ -235,14 +245,14 @@ The shell script `$SCRIPT_DIR/run.sh` has commands, that are used for operating
235
245
```
236
246
237
247
-`cleanup-temp-user-dirs`: usually called from cron. It takes a server name and runs a shell in the corresponding container, that will remove temporary old
238
-
data allocated by the crosscompiler. It is assumed, that these crosscompiler-allocated files are used not longer than one day after their creation.
248
+
data allocated by the cross-compiler. It is assumed, that these files allocated by the cross-compiler are used not longer than one day after their creation.
239
249
Use `crontab -e` to add the following line to the crontab to remove garbage every night 20 minutes after two o'clock:
-`auto-restart`: this command spawns a process, that will not terminate by itself. It checks the availablity of the server (using the server-url)
255
+
-`auto-restart`: this command spawns a process, that will not terminate by itself. It checks the availability of the server (using the server-url)
246
256
and, if the server is not available when tried to access twice, it will restart the server. Logging info is written to `<BASE_DIR>/logs/autorestart.txt`. the
247
257
pid of the auto-restart process is logged. The process may be terminated at any time. The process can be initiated explicitly by executing:
248
258
@@ -319,26 +329,26 @@ This feature is needed to protect against data loss if a server crashes. As the
319
329
the backups are copied, must be at least the safety requirements for the machine, that runs the database server. Ssh keys are used, thus a setup on both servers
320
330
is needed. The two servers affected are called "SRC-SERVER" and "TARGET-SERVER".
321
331
322
-
- On the TARGET-SERVER: check whether `ssh <anyExistingUser@TARGET-SERVER` succeeds.
323
-
- On the TARGET-SERVER: `adduser dbBackup --force-badname`. The user's password has to be strong.
324
-
- On the TARGET-SERVER: `cd <BASE_DIR_ON_TGT_S>/db/dbAdmin; mkdir -p dbBackupSave/<db-name>`
- On the TARGET-SERVER: `su dbBackup` and in the shell opened run `ssh-keygen -t rsa -b 4096`
337
+
- On the SRC-SERVER: `adduser dbBackup --force-badname`. The user's password has to be strong
328
338
- On the SRC-SERVER: `cd <BASE_DIR_ON_SRC_S>/db/dbAdmin; chgrp -R dbBackup dbBackup; chmod -R g+rwx dbBackup`
329
-
- On the TARGET-SERVER: `ssh-copy-id -i /home/dbBackup/.ssh/id_rsa.pub dbBackup@<SRC-SERVER>; ssh dbBackup@<SRC-SERVER> # test for success`.
339
+
- On the TARGET-SERVER: `ssh-copy-id -i /home/dbBackup/.ssh/id_rsa.pub dbBackup@<SRC-SERVER>; ssh dbBackup@<SRC-SERVER> # test for success`
330
340
331
341
How does it work?
332
342
333
343
- On SRC-SERVER (for instance every day at 2:00 AM started by a cronjob) a database backup is generated. See the description above, how to achieve that. The
334
344
backup is readable by all members of group `dbBackup`, to which user `dbBackup` belongs.
335
345
- On TARGET-SERVER (for instance every day at 3:00 AM started by a cronjob) the database backup is saved to protect us against data loss. This works, because
336
-
user `dbBackup` on TARGET-SERVER can use `scp` for user `dbBackup` on SRC-SERVER and the ssh key installed above allows that. The rights on SRC-SERVER are
337
-
restricted to the rights of user `dbBackup` on SRC-SERVER. Essentially this is the access to the backup directory.
338
-
`The cronjob on TARGET-SERVER could look like (note, that the script runs as user`dbBackup`, and, that cron expects the command in one line).
346
+
user `dbBackup` on TARGET-SERVER can use `scp` for user `dbBackup` on SRC-SERVER, as the ssh key installed above allows that. The rights of the scp command
347
+
are restricted to accessing the backup directory.
348
+
- You can automate this by a crontab entry on TARGET-SERVER (note, that the script runs as user`dbBackup`, and, that cron expects the command in one line).
@@ -356,4 +366,4 @@ arbitrary number of command line arguments like `-d KEY=VALUE`. The final list o
356
366
mount points.
357
367
- variable `START_ARGS`: every OpenRoberta server has a configuration file `decl.sh`. Here the shell variable `START_ARGS` can define more `-d` arguments.
358
368
_NOTE:_ this is the place for the last deployer-defined additions: declare the list of robot plugins to use, whether this is the public server or not, and so
359
-
on. It is possible, but _not_adviced to overwrite properties already defined at the two other places described above
369
+
on. It is possible, but _not_advised to overwrite properties already defined at the two other places described above
0 commit comments