Skip to content

Commit eae37a0

Browse files
committed
improve the README
1 parent a1e8fa6 commit eae37a0

File tree

3 files changed

+46
-37
lines changed

3 files changed

+46
-37
lines changed

.idea/misc.xml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+44-34
Original file line numberDiff line numberDiff 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)
22

33
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
44
[wiki on GitHub](https://github.com/OpenRoberta/openroberta-lab/wiki/Instructions-to-run-a-openroberta-lab-server-using-DOCKER). This text describes the
55
docker-related scripts, which are used for a large installation (as our prod and test servers are),
66

7-
- to setup a docker network,
7+
- to set up a docker network,
88
- create docker images for a data base server and lab server and
99
- run docker container of the OpenRoberta lab.
1010

1111
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.
1313

1414
`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+
```
1525

1626
## Create an instance of our docker installation
1727

1828
- run `git clone https://github.com/OpenRoberta/docker`.
1929

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.
2131
- move the docker git repository to `<BASEDIR>/git`. You may need it later to update the docker installation.
2232
- cd to `<BASEDIR>/git` and call `git clone https://github.com/OpenRoberta/openroberta-lab`. This repository is needed later when docker images are generated.
2333
- cd to `<BASEDIR>/git/openroberta-lab` and call `mvn clean install -DskipTests`. This must succeed. The generated resources are needed if you want
2434
to create empty databases later.
2535

2636
- **create the servers you need** by calling `./ora.sh new-server-in-docker-setup <BASEDIR> <SERVER>`. Note, that `test, dev, dev1...dev9` are the
2737
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
3040
- if you cd to `<BASEDIR>/git/openroberta-lab` and
3141
- call `./admin.sh -git-mode -db-parentdir <BASEDIR>/db/<SERVER> create-empty-db`
3242
- in the global `<BASEDIR>/decl.sh`
@@ -41,7 +51,7 @@ You have to
4151
- create a new docker bridge network (`RUN gen-net`). The name of the network is defined in the global `decl.sh`.
4252
- 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
4353
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/...`
4555

4656
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
4757
iais.fraunhofer.de
@@ -52,20 +62,20 @@ iais.fraunhofer.de
5262
5363
# (re-)create the base image (done from time to time)
5464

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
5666
the `decl.sh` of each server. It contains all software needed by the lab to create binaries for all the robots, i.e.
5767

58-
- the crosscompiler binaries itself. They are installed by calling `apt`, `wget`, ... .
59-
- header, libraries, scripts, ..., to be used together with the cross compiler.
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.
6070

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
6272
the `openroberta/base-${ARCH}` image is derived. This occurs more often. Both images have an independent version numbering.
6373

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.
6575
Name: `openroberta/ccbin-x64:<number>>`. The current version (19.4.2023) is _2_. The image is created using the shell
6676
command `RUN gen_ccbin <arch> <ccbin-version>`. The last build was `RUN gen_ccbin x64 2`.
6777

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
6979
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
7080
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,
7181
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.
8393
# Operating Instructions for the Test and Prod Server
8494

8595
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
8797
named `master` only).
8898

8999
## Directory structure
90100

91101
The template for our framework is contained in directory `Docker/openroberta`. It contains the directories
92102

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
94104

95105
- scripts - contains shell scripts to administrate the framework. The main script is `run.sh`. Call it without parameters to get help. the directory `helper`
96106
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
139149
## Web server software
140150

141151
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
144154

145155
- `container:1999` is mapped to
146156
- `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`
148158

149159
The nginx configuration examples are in the directory `z-nginx`. The configuration directory on the host machine is `/etc/nginx/`. In the example
150160
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.
157167
All data is stored relative to a base directory `$BASE_DIR` (your choice, we use `/data/openroberta-lab`). Abbreviations:
158168

159169
```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
161171
CONF_DIR=$BASE_DIR/conf
162172
SCRIPT_DIR=$BASE_DIR/scripts
163173
SERVER_DIR=$BASE_DIR/server
@@ -219,7 +229,7 @@ The database server is listening to the port `$DATABASE_SERVER_PORT` as defined
219229

220230
The shell script `$SCRIPT_DIR/run.sh` has commands, that are used for operating purposes.
221231

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
223233
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:
224234

225235
```bash
@@ -235,14 +245,14 @@ The shell script `$SCRIPT_DIR/run.sh` has commands, that are used for operating
235245
```
236246

237247
- `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 cross compiler. 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.
239249
Use `crontab -e` to add the following line to the crontab to remove garbage every night 20 minutes after two o'clock:
240250

241251
```bash
242252
20 2 * * * bash <SCRIPT_DIR>/run.sh -q admin <server-name> cleanup-temp-user-dirs >><BASE_DIR>/logs/cronlog.txt
243253
```
244254

245-
- `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)
246256
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
247257
pid of the auto-restart process is logged. The process may be terminated at any time. The process can be initiated explicitly by executing:
248258

@@ -319,26 +329,26 @@ This feature is needed to protect against data loss if a server crashes. As the
319329
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
320330
is needed. The two servers affected are called "SRC-SERVER" and "TARGET-SERVER".
321331

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>`
325-
`chgrp dbBackup dbBackupSave dbBackupSave/<db-name>; chmod -R g+rwx dbBackup`.
326-
- On the TARGET-SERVER: `su dbBackup; ssh-keygen -t rsa -b 4096`.
327-
- On the SRC-SERVER: `adduser dbBackup --force-badname`. The user's password has to be strong.
332+
- On the TARGET-SERVER: check whether `ssh <anyExistingUser@TARGET-SERVER` succeeds
333+
- On the TARGET-SERVER: `adduser dbBackup --force-badname`. The user's password has to be strong
334+
- On the TARGET-SERVER: `cd <BASE_DIR_ON_TGT_SERVER/db/dbAdmin; mkdir -p dbBackupSave/<db-name>`
335+
`chgrp dbBackup dbBackupSave dbBackupSave/<db-name>; chmod -R g+rwx dbBackupSave`
336+
- 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
328338
- 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`
330340

331341
How does it work?
332342

333343
- 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
334344
backup is readable by all members of group `dbBackup`, to which user `dbBackup` belongs.
335345
- 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).
339349

340350
```bash
341-
0 3 * * * /usr/bin/sudo -u dbBackup <SCRIPT_DIR_ON_TGT_S>/run.sh -q backup-save
351+
0 3 * * * /usr/bin/sudo -u dbBackup <BASE_DIR_ON_TGT_SERVER>/scripts/run.sh -q backup-save
342352
dbBackup@<SRC-SERVER>:<BASE_DIR_ON_SRC_S>/db/dbAdmin/dbBackup/<db-name> db/dbAdmin/dbBackupSave/<db-name>
343353
>><BASE_DIR>/logs/cronlog.txt 2>&1
344354
```
@@ -356,4 +366,4 @@ arbitrary number of command line arguments like `-d KEY=VALUE`. The final list o
356366
mount points.
357367
- variable `START_ARGS`: every OpenRoberta server has a configuration file `decl.sh`. Here the shell variable `START_ARGS` can define more `-d` arguments.
358368
_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

ora.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ new-docker-setup) base_dir="$1"
3131
fi
3232
cp -r openroberta $base_dir
3333
cp README.md $base_dir
34-
echo 'New docker setup created in $base_dir. Please read the README.md of the git repository "OpenRoberta/docker"' ;;
34+
echo "New docker setup created in $base_dir. Please read the README.md of the git repository \"OpenRoberta/docker\"" ;;
3535

3636
new-server-in-docker-setup)
3737
base_dir="$1"
@@ -49,7 +49,7 @@ new-server-in-docker-setup)
4949
exit 12
5050
fi
5151
cp -r openroberta/server/_server-template $server_dir
52-
echo "New server $server_name created. Please read the README.md of the git repository \"OpenRoberta/docker\"" ;;
52+
echo "New server $server_name created. Please read the README.md of the git repository 'OpenRoberta/docker'" ;;
5353

5454
update-docker-setup)
5555
base_dir="$1"

0 commit comments

Comments
 (0)