Skip to content

Commit 2fdabc4

Browse files
committed
supply env-default file, and gitignore .env;
add reference to .env file in compose file, to elicit a useful error message when the user has not created the .env file. Update the README file.
1 parent 07b41ba commit 2fdabc4

File tree

4 files changed

+64
-21
lines changed

4 files changed

+64
-21
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.vscode/settings.json
2+
3+
nuodb/.env

README.md

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,64 @@
1-
# nuodb-compose
1+
# nuodb-compose #
22
Docker compose files for starting a nuodb database on the local host.
33

44
These docker compose files will create:
55
* a new docker network specifically for this database;
6-
* separate AP (admin), TE, and SM containers for each NuoDB process;
6+
* separate AP (admin), TE, and SM containers - one for each NuoDB process;
77
* a separate CD (collector) container for each engine container - to enable NuoDB Insights;
8-
* an influxdb and grafana container to host the NuoDB Insights dashboards.
8+
* influxdb and grafana containers to host the NuoDB Insights dashboards.
99

1010
Note that the container names will have the `project` name embedded - which is the name of the directory (`nuodb`), or set with the `-p` option to `docker-compose`.
1111

12-
# Instructions
13-
0. clone the repo;
14-
1. cd to the `nuodb` directory;
15-
2. edit the `.env` file
16-
- if you want to use the a specific SQL engine, you will need an image that supports that engine;
17-
- if you want to access the database from outside the `docker network` then set `EXTERNAL_ADDRESS`
18-
-- either in the `.env` file, _or_ by setting `EXTERNAL_ADDRESS` on the `docker-compose up` command-line;
19-
- if you want to import initial state from a backup into the new database, set `IMPORT_SOURCE` to a path
20-
on the _local_ machine. The SM container will mount this file as a volume and extract (untar) it into the
12+
# Instructions #
13+
## Creating the database ##
14+
0. clone the repo.
15+
16+
1. cd to the `nuodb` directory.
17+
18+
2. copy the `env-default` file to `.env` (this step is _NOT_ optional).
19+
20+
3. edit the `.env` file:
21+
- if you want to use a specific SQL engine - for example `scalar` - you will need an image that supports that engine;
22+
- if you want to access the database from outside the `docker network` - for example from an app running direcly on the local host - then set `EXTERNAL_ADDRESS`;
23+
- either in the `.env` file, _or_ by setting `EXTERNAL_ADDRESS` on the `docker-compose up` command-line;
24+
- if you want to import initial state from a database backup into the new database, set `IMPORT_SOURCE` to a path
25+
on the _local_ machine. The SM container will mount this file as a volume and extract (`untar`) it into the
2126
archive dir prior to starting the SM process;
22-
(only if the archive dir is empty - so the SM container can be stopped and restarted without being reinitialised.)
23-
-- if you have set `IMPORT_SOURCE` _and_ it is a large file that takes multiple minutes to extract, you _may_ need to
24-
set `STARTUP_TIMEOUT` to a larger value, to stop the starup from timeing our _before_ the IMPORT has completed.
25-
3. create and start the nuodb database with `docker-compose up -d`;
26-
4. stop and delete everything with `docker-compose down`;
27-
28-
To specify env vars on the command-line, specify them _before_ the `docker-compose` command.
29-
Ex: `IMPORT_SOURCE=./mydb.bak.tgz STARTUP_TIMEOUT=300 docker-compose up -d`
27+
- this is only done only when the archive dir is _empty_ - so the SM container can be stopped and restarted without being reinitialised.
28+
- if you have set `IMPORT_SOURCE` _and_ it is a large file that takes multiple minutes to extract, you _will_ need to
29+
set `STARTUP_TIMEOUT` to a larger value, to stop the startup from timing out before the IMPORT has completed.
30+
31+
4. create and start the nuodb database with `docker-compose up -d`.
32+
33+
## Stopping the database ##
34+
1. To stop all containers, but retain all stored state including the database contents:
35+
- cd to the `nuodb` directory;
36+
- execute `docker-compose down`
37+
38+
2. To restart a stopped database - complete with the database contents:
39+
- cd to the `nuodb` directory;
40+
- execute `docker-compose start`.
41+
42+
## Deleting the database and all its storage ##
43+
1. To stop all containers, and delete all resources - including the stored state and database contents:
44+
- cd to the `nuodb` directory;
45+
- execute `docker-compose down`.
46+
47+
## Notes ##
48+
1. You can specify env vars on the command-line in linux or MacOS, by setting them _before_ the `docker-compose` command.
49+
- Ex: `$ IMPORT_SOURCE=./mydb.bak.tgz STARTUP_TIMEOUT=300 docker-compose up -d`
50+
51+
## What could possibly go wrong?? ##
52+
53+
1. If you get an error in the form:
54+
```
55+
WARNING: The NUODB_IMAGE variable is not set. Defaulting to a blank string.
56+
WARNING: The PEER_ADDRESS variable is not set. Defaulting to a blank string.
57+
WARNING: The IMPORT_SOURCE variable is not set. Defaulting to a blank string.
58+
...
59+
ERROR: Couldn't find env file: /a/b/c/nuodb/.env
60+
```
61+
- then you have most likely forgotten to copy the `env-default` file to `.env`;
62+
- or (less popular) create your own `.env` file from scratch.
63+
64+
2. If an error causes only part of the database to be deployed, you can start the remaining containers - after fixing the error - by simply running `docker-compose up -d` again. The `up` command only starts those containers that are missing.

nuodb/docker-compose.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ version: '3'
22
services:
33
nuoadmin1:
44
image: $NUODB_IMAGE
5+
6+
# Do NOT remove this env_file value!!
7+
env_file: .env
8+
59
environment:
610
NUODB_DOMAIN_ENTRYPOINT: $PEER_ADDRESS
711
hostname: $PEER_ADDRESS
@@ -35,6 +39,7 @@ services:
3539
- "sh"
3640
- "-c"
3741
- |
42+
echo "ARCHIVE_DIR=$$ARCHIVE_DIR"
3843
if [ -n "$IMPORT_SOURCE" -a -f "$IMPORT_PATH" -a ! -f $$ARCHIVE_DIR/1.atm ]; then
3944
echo "Importing from $IMPORT_PATH into $$ARCHIVE_DIR..."
4045
tar xf $IMPORT_PATH --strip-components ${IMPORT_LEVEL:-1} -C $$ARCHIVE_DIR || exit 98
@@ -138,7 +143,7 @@ services:
138143
depends_on:
139144
- influxdb
140145
environment:
141-
- INFLUX_HOST=influxdb
146+
INFLUX_HOST: influxdb
142147
volumes:
143148
- ./provisioning:/etc/grafana/provisioning
144149
ports:

nuodb/.env renamed to nuodb/env-default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ARCHIVE_PATH=
2323
# set IMPORT_SOURCE to the path of a LOCAL file on the host where docker-compose is being run.
2424
# It will be mounted from that location into the SM container, from where it will be extracted
2525
# and used as the initial state of the database.
26+
# The person supplying the backup TAR file can advise on any non-standard values required for IMPORT_LEVEL.
2627
IMPORT_SOURCE=
2728
IMPORT_LEVEL=1
2829
IMPORT_PATH=/var/opt/nuodb/import.tz

0 commit comments

Comments
 (0)