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
Allow configuring from environment, add docker entrypoint (#229)
* Allow setting most config variables through environment
* Add docker entrypoint
* Update config docs
* Update deployment docs
* Change unit test after setting TLS to true by default
* Get media base dir from env
* Bump Grampsjs version in docs
Copy file name to clipboardExpand all lines: docs/Configuration.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
# Configuration
2
2
3
-
A configuration file is necessary to run the Gramps Web API. Its path can either be provided on the command line when running the module as a script (`python3 -m gramps_webapi --config path/to/config.cfg ...`), or as an environment variable, `GRAMPS_API_CONFIG=path/to/config.cfg`.
3
+
Some configuration is necessary to run the Gramps Web API. When using a configuration file, its path can either be provided on the command line when running the module as a script (`python3 -m gramps_webapi --config path/to/config.cfg ...`), or as an environment variable, `GRAMPS_API_CONFIG=path/to/config.cfg`. Some of the configuration options can also be set without a configuration file, using environment variables (e.g. `TREE='My Tree' python3 -m gramps_webapi ...` ).
4
4
5
-
The following settings can be specified in the configuration file.
5
+
The following configuration options exist. The last column indicates whether the option can be set from an environment variable.
6
6
7
7
8
8
## Required settings
9
9
10
-
Key | Description
11
-
----|------------
12
-
`TREE` | The name of the family tree database to use. Show available trees with `gramps -l`
13
-
`SECRET_KEY` | The secret key for flask. This must be set for use in production. The secret must not be shared publicly. Changing it will invalidate all access tokens.`
10
+
Key | Description | Set from environment
11
+
----|-------------|---------------------
12
+
`TREE` | The name of the family tree database to use. Show available trees with `gramps -l` | yes
13
+
`SECRET_KEY` | The secret key for flask. This must be set for use in production. The secret must not be shared publicly. Changing it will invalidate all access tokens | yes
14
14
15
15
!!! info
16
16
You can generate a secure secret key e.g. with the command
@@ -21,27 +21,27 @@ Key | Description
21
21
22
22
## Optional settings
23
23
24
-
Key | Description
25
-
----|------------
26
-
`MEDIA_BASE_DIR` | Path to use as base directory for media files, overriding the media base directory set in Gramps
27
-
`SEARCH_INDEX_DIR` | Path for the full-text search index. Defaults to `indexdir` relative to the path where the script is run
28
-
`STATIC_PATH` | Path to serve static files from (e.g. a static web frontend)
29
-
`BASE_URL` | Base URL where the API can be reached (e.g. `https://mygramps.mydomain.com/`). This is necessary e.g. to build correct passwort reset links
30
-
`CORS_ORIGINS` | Origins where CORS requests are allowed from. By default, all are disallowed. Use `"*"` to allow requests from any domain.
31
-
`EMAIL_HOST` | SMTP server host (e.g. for sending password reset e-mails)
32
-
`EMAIL_PORT` | SMTP server port
33
-
`EMAIL_HOST_USER` | SMTP server username
34
-
`EMAIL_HOST_PASSWORD` | SMTP server password
35
-
`EMAIL_USE_TLS` | Boolean, whether to use TLS for sending e-mails. Defaults to false
36
-
`DEFAULT_FROM_EMAIL` | "From" address for automated e-mails
37
-
`THUMBNAIL_CACHE_CONFIG` | Dictionary with settings for the thumbnail cache. See [Flask-Caching](https://flask-caching.readthedocs.io/en/latest/) for possible settings.
24
+
Key | Description | Set from environment
25
+
----|-------------|---------------------
26
+
`MEDIA_BASE_DIR` | Path to use as base directory for media files, overriding the media base directory set in Gramps | yes
27
+
`SEARCH_INDEX_DIR` | Path for the full-text search index. Defaults to `indexdir` relative to the path where the script is run | yes
28
+
`STATIC_PATH` | Path to serve static files from (e.g. a static web frontend) | yes
29
+
`BASE_URL` | Base URL where the API can be reached (e.g. `https://mygramps.mydomain.com/`). This is necessary e.g. to build correct passwort reset links | yes
30
+
`CORS_ORIGINS` | Origins where CORS requests are allowed from. By default, all are disallowed. Use `"*"` to allow requests from any domain. | no
31
+
`EMAIL_HOST` | SMTP server host (e.g. for sending password reset e-mails) | yes
32
+
`EMAIL_PORT` | SMTP server port. defaults to 465 | yes
33
+
`EMAIL_HOST_USER` | SMTP server username | yes
34
+
`EMAIL_HOST_PASSWORD` | SMTP server password | yes
35
+
`EMAIL_USE_TLS` | Boolean, whether to use TLS for sending e-mails. Defaults to true | no
36
+
`DEFAULT_FROM_EMAIL` | "From" address for automated e-mails | yes
37
+
`THUMBNAIL_CACHE_CONFIG` | Dictionary with settings for the thumbnail cache. See [Flask-Caching](https://flask-caching.readthedocs.io/en/latest/) for possible settings. | no
38
38
39
39
40
40
## Settings only during development
41
41
42
-
Key | Description
43
-
----|------------
44
-
`DISABLE_AUTH` | If `True`, disable the authentication system. **Warning: never** use this in a production environment, as it will allow read and write access from the public!
42
+
Key | Description | Set from environment
43
+
----|-------------|---------------------
44
+
`DISABLE_AUTH` | If `True`, disable the authentication system. **Warning: never** use this in a production environment, as it will allow read and write access from the public! | no
Copy file name to clipboardExpand all lines: docs/Deployment.md
+19-32Lines changed: 19 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,24 +23,7 @@ Upload your media files to the server. Make sure your Gramps database uses relat
23
23
Use the "Convert media paths from absolute to relative" option in the "Media Manager" tool in Gramps' "Tools" menu if necessary.
24
24
25
25
26
-
27
-
## Step 3: Create a configuration file
28
-
29
-
Create a configuration and upload it to your server (we will assume the path is `~/config.cfg`). It should contain at least the following lines:
30
-
31
-
```python
32
-
TREE="..."# set the name of your family tree
33
-
SECRET_KEY="..."# set your secret key
34
-
# do not change the following lines as they refer to paths within the container
35
-
USER_DB_URI="sqlite:////app/users/users.sqlite"
36
-
MEDIA_BASE_DIR="/app/media"
37
-
SEARCH_INDEX_DIR="/app/indexdir"
38
-
STATIC_PATH="/app/static"
39
-
```
40
-
41
-
For other configuration options, see [Configuration](Configuration.md)
42
-
43
-
## Step 4: Docker configuration
26
+
## Step 3: Docker configuration
44
27
45
28
Create a new file on the server named `docker-compose.yml` and insert the following contents:
46
29
@@ -53,11 +36,14 @@ services:
53
36
restart: always
54
37
ports:
55
38
- "80:5000"
39
+
environment:
40
+
TREE: "..."# set the name of your family tree
41
+
SECRET_KEY: "..."# set your secret key
42
+
BASE_URL: "http://localhost:5554"
56
43
volumes:
57
44
- gramps_users:/app/users
58
45
- gramps_index:/app/indexdir
59
46
- gramps_thumb_cache:/app/thumbnail_cache
60
-
- ~/config.cfg:/app/config/config.cfg
61
47
- ~/gramps_db:/root/.gramps/grampsdb
62
48
- ~/gramps_media:/app/media
63
49
@@ -67,14 +53,14 @@ volumes:
67
53
gramps_thumb_cache:
68
54
```
69
55
70
-
This will generate three named volumes to make sure that the user database, search index, and thumbnail cache will persist, and will mount the configuration file, Gramps database directory, and the directory holding your media files into the container (the paths on the left-hand side of the colon `:` refer to your host machine, the ones on the right hand side to the container and should not be changed).
56
+
This will generate three named volumes to make sure that the user database, search index, and thumbnail cache will persist, and will mount the Gramps database directory and the directory holding your media files into the container (the paths on the left-hand side of the colon `:` refer to your host machine, the ones on the right hand side to the container and should not be changed). For more configuration options, see [Configuration](Configuration.md).
71
57
72
58
!!! warning
73
59
The above will make the API available on port 80 of the host machine **without SSL/TLS protection**. You can use this for local testing, but do not expose this directly to the internet, it is completely insecure!
74
60
75
61
76
62
77
-
## Step 5: Secure access with SSL/TLS
63
+
## Step 4: Secure access with SSL/TLS
78
64
79
65
The web API **must** be served to the public internet over HTTPS. There are several options, e.g.
80
66
@@ -156,7 +142,7 @@ networks:
156
142
157
143
Please see the [acme-companion](https://github.com/nginx-proxy/acme-companion) docs for how to set up your domain.
158
144
159
-
## Step 6: Import database
145
+
## Step 5: Import database
160
146
161
147
If you have copied the Gramps database directory directly in Step 1, you can skip this step.
162
148
@@ -172,7 +158,7 @@ docker-compose run gramps_webapi \
172
158
where `My family tree` is the name of the new family tree (must match the setting in the config file) and `my_tree.gramps` the file name of the Gramps XML export.
173
159
174
160
175
-
## Step 7: Add users
161
+
## Step 6: Add users
176
162
177
163
Initialize the user system by creating an administrator account with the command
178
164
@@ -188,19 +174,20 @@ docker-compose run gramps_webapi \
188
174
See [User system](Users.md) for more details and how to add additional users.
189
175
190
176
191
-
## Step 8: Build the search index
177
+
## Step 7: Start the server
192
178
193
-
Build the initial search index by running
179
+
Run
194
180
195
-
```bash
196
-
docker-compose run gramps_webapi \
197
-
python3 -m gramps_webapi search index-full
181
+
```
182
+
docker-compose up -d
198
183
```
199
184
200
-
## Step 9: Start the server
185
+
On first run, it will build the full-text search index of the API.
201
186
202
-
Run
187
+
## Optional step: use Gramps.js web frontend
203
188
189
+
If you want to add the [Gramps.js](https://github.com/DavidMStraub/Gramps.js) web frontend to your installation, simply add
190
+
```yaml
191
+
- GRAMPSJS_VERSION=v0.1.1
204
192
```
205
-
docker-compose up -d
206
-
```
193
+
(or any other released version) to the `environment` block in the `gramps_webapi` service section of `docker-compose.yml`.
0 commit comments