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: docs/_docs/install/settings.md
+50-32Lines changed: 50 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,16 @@ toc: false
6
6
7
7
# Settings
8
8
9
-
See that folder called [settings](https://github.com/singularityhub/sregistry/blob/master/shub/settings)? inside are a bunch of different starting settings for the application. We will change them in these files before we start the application. There are actually only two files you need to poke into, generating a `settings/secrets.py` from our template [settings/dummy_secrets.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings/dummy_secrets.py) for application secrets, and [settings/config.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings/config.py) to configure your database and registry information.
9
+
As of version `1.1.41` we have one core [settings.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings.py) file
10
+
that can be populated in several ways:
11
+
12
+
- Directly in the file (e.g., if you build your own base container)
13
+
- From the environment (described below with a `SREGISTRY_` prefix
14
+
- From a config file, `settings.yaml` in the root directory of your server OR custom set at `SREGISTRY_SETTINGS_FILE`
15
+
16
+
You will want to choose a strategy that works for your deployment, and then tweak the values to your liking before we start the application.
17
+
For example, if you are running sregistry on a filesystem directly that you can access, you can easily write secrets into a `secrets.py` in the
18
+
`shub/` directory alongside settings and you can use the [dummy_secrets.py](https://github.com/singularityhub/sregistry/blob/master/shub/dummy_secrets.py) as a starter template. However, if you are deploying via Kubernetes or similar, you can either choose to define secrets entirely in the environment, or you can have a `settings.yaml` that is created in a manifest and passed to the application.
10
19
11
20
## Environment
12
21
@@ -29,8 +38,24 @@ are exposed (all strings):
29
38
- SREGISTRY_DATABASE_HOST (db)
30
39
- SREGISTRY_DATABASE_PORT (5432)
31
40
32
-
And you can set a custom set of comma separated values for either of `SREGISTRY_ADMINS` or `SREGISTRY_PLUGINS_ENABLED`.
33
-
Each of these settings is explained in more detail in the sections below.
41
+
And you can set a custom set of comma separated values (in a string) for either of `SREGISTRY_ADMINS` or `SREGISTRY_PLUGINS_ENABLED`.
42
+
43
+
```console
44
+
SREGISTRY_ADMINS="adminA,adminB,adminC"
45
+
SREGISTRY_PLUGINS_ENABLED="ldap,google-build"
46
+
```
47
+
48
+
Finally, if you need to set secrets from the environment (and don't want to provide the secrets.py file) you can
49
+
do the same by taking any secret value and prefixing it with `SREGISTRY_SECRET_`. For this approach, we currently
50
+
support strings and booleans (true/false derivatives) and we can add support for other types if requested.
51
+
52
+
For example, to set your secret key (required) you would do:
Or, if you prefer a clean secrets file, create a blank one as below:
46
71
47
72
```bash
48
-
touch shub/settings/secrets.py
73
+
touch shub/secrets.py
49
74
```
50
75
51
76
and inside you want to add a `SECRET_KEY`. You can use the [secret key generator](http://www.miniwebtool.com/django-secret-key-generator/) to make a new secret key, and call it `SECRET_KEY` in your `secrets.py` file, like this:
@@ -54,9 +79,15 @@ and inside you want to add a `SECRET_KEY`. You can use the [secret key generator
One thing I (@vsoch) can't do for you in advance is produce application keys and secrets to give your Registry for each social provider that you want to allow users (and yourself) to login with. We are going to use a framework called [python social auth](https://python-social-auth-docs.readthedocs.io/en/latest/configuration/django.html) to achieve this, and in fact you can add a [number of providers](http://python-social-auth-docs.readthedocs.io/en/latest/backends/index.html) (I have set up a lot of them, including SAML, so please <a href="https://www.github.com/singularityhub/sregistry/isses" target="_blank">submit an issue</a> if you want one added to the base proper.). Singularity Registry uses OAuth2 with a token--> refresh flow because it gives the user power to revoke permission at any point, and is a more modern strategy than storing a database of usernames and passwords. You can enable or disable as many of these that you want, and this is done in the [settings/config.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings/config.py):
90
+
One thing I (@vsoch) can't do for you in advance is produce application keys and secrets to give your Registry for each social provider that you want to allow users (and yourself) to login with. We are going to use a framework called [python social auth](https://python-social-auth-docs.readthedocs.io/en/latest/configuration/django.html) to achieve this, and in fact you can add a [number of providers](http://python-social-auth-docs.readthedocs.io/en/latest/backends/index.html) (I have set up a lot of them, including SAML, so please <a href="https://www.github.com/singularityhub/sregistry/isses" target="_blank">submit an issue</a> if you want one added to the base proper.). Singularity Registry uses OAuth2 with a token--> refresh flow because it gives the user power to revoke permission at any point, and is a more modern strategy than storing a database of usernames and passwords. You can enable or disable as many of these that you want, and this is done in the [settings.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings.py), which is controllable via the environment or a `settings.yaml` or by editing the file directly:
60
91
61
92
62
93
```python
@@ -69,7 +100,8 @@ ENABLE_BITBUCKET_AUTH=False
69
100
ENABLE_GITHUB_ENTERPRISE_AUTH=False
70
101
```
71
102
72
-
and you will need at least one to log in. I've found that GitHub works the fastest and easiest, and then Google.
103
+
Any of the above can be set in the environment with the `SREGISTRY_` prefix.
104
+
You will need at least one to log in. I've found that GitHub works the fastest and easiest, and then Google.
73
105
Twitter now requires an actual server name and won't work with localhost, but if you are deploying on a server with a proper domain go ahead and use it. All avenues are extremely specific with regard to callback urls, so you should be very careful in setting them up. If you want automated builds from a repository
74
106
integration with Google Cloud Build, then you must use GitHub.
75
107
@@ -158,7 +190,6 @@ Where the key and secret are replaced by the ones given to you. If you have a pr
Finally, don't forget to enable the bitbucket login in settings/config.py:
222
+
Finally, don't forget to enable the bitbucket login in settings.py:
192
223
193
224
```python
194
225
ENABLE_BITBUCKET_AUTH=True
@@ -206,24 +237,19 @@ Note that Twitter now does not accept localhost urls. Thus,
206
237
the callback url here should be `http://[your-domain]/complete/twitter`.
207
238
208
239
209
-
210
-
## Config
211
-
212
-
In the [config.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings/config.py) you need to define the following:
213
-
214
240
### Google Analytics
215
241
216
-
If you want to add a Google analytics code, you can do this in the settings/config.py:
242
+
If you want to add a Google analytics code, you can do this in the settings.py:
217
243
218
244
```python
219
245
GOOGLE_ANALYTICS="UA-XXXXXXXXX"
220
246
```
221
247
222
248
The default is set to None, and doesn't add analytics to the registry.
223
249
224
-
225
250
### Domain Name
226
-
A Singularity Registry Server should have a domain. It's not required, but it makes it much easier for yourself and users to remember the address. The first thing you should do is change the `DOMAIN_NAME_*` variables in your settings [settings/config.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings/config.py#L30).
251
+
252
+
A Singularity Registry Server should have a domain. It's not required, but it makes it much easier for yourself and users to remember the address. The first thing you should do is change the `DOMAIN_NAME_*` variables in your settings [settings.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings.py).
227
253
228
254
For local testing, you will want to change `DOMAIN_NAME` and `DOMAIN_NAME_HTTP` to be localhost. Also note that I've set the regular domain name (which should be https) to just http because I don't have https locally:
229
255
@@ -238,6 +264,7 @@ It's up to the deployer to set one up a domain or subdomain for the server. Typi
238
264
239
265
240
266
### Registry Contact
267
+
241
268
You need to define a registry uri, and different contact information:
242
269
243
270
```python
@@ -365,7 +392,7 @@ For other disable and limit arguments (for GitHub, creating, or receiving builds
365
392
366
393
By default, the database itself will be deployed as a postgres image called `db`. You probably don't want this for production (for example, I use a second instance with postgres and a third with a hot backup, but it's an ok solution for a small cluster or single user. Either way, we recommend backing it up every so often.
367
394
368
-
When your database is set up, you can define it in your `secrets.py` and it will override the Docker image one in the `settings/main.py file`. It should look something like this
395
+
When your database is set up, you can define it in your `secrets.py` and it will override the Docker image one in the `settings.py file`. It should look something like this
369
396
370
397
```python
371
398
DATABASES= {
@@ -381,6 +408,7 @@ DATABASES = {
381
408
```
382
409
383
410
### Logging
411
+
384
412
By default, Singularity Registry keeps track of all requests to pull containers, and you have control over the level of detail that is kept. If you want to save complete metadata (meaning the full json response for each call) then you should set `LOGGING_SAVE_RESPONSES` to True. If you expect heavy use and want to save the minimal (keep track of which collections are pulled how many times) the reccomendation is to set this to False.
385
413
386
414
```python
@@ -389,28 +417,18 @@ LOGGING_SAVE_RESPONSES=True
389
417
390
418
## API
391
419
392
-
Take a look in [settings/api.py](https://github.com/singularityhub/sregistry/blob/master/shub/settings/api.py)
393
-
to configure your restful API. You can uncomment the first block to require authentication:
420
+
To configure your restful API you can set `SREGISTRY_API_REQUIRE_AUTH` to true.
394
421
395
422
```python
396
423
'DEFAULT_PERMISSION_CLASSES': (
397
424
'rest_framework.permissions.IsAuthenticated',
398
425
),
399
426
```
400
427
401
-
And also choose throttle rates for users and anonymous API requests.
428
+
And also choose throttle rates for users and anonymous API requests
429
+
with the following:
430
+
402
431
403
-
```python
404
-
# You can also customize the throttle rates, for anon and users
# if you want to specify a version of Singularity. The version must coincide with a container tag hosted under singularityware/singularity. The version will default to 3.2.0-slim If you want to use a different version, update this variable.
# Additionally, a temporary bucket is created with the same name ending in _cloudbuild. This bucket is for build time dependencies, and is cleaned up after the fact. If you are having trouble getting a bucket it is likely because the name is taken,
95
95
# and we recommend creating both <name> and <name>_cloudbuild in the console and then setting the name here.
96
96
97
-
# SREGISTRY_GOOGLE_BUILD_TIMEOUT_SECONDS=None
97
+
# GOOGLE_BUILD_TIMEOUT_SECONDS=None
98
98
# The number of seconds for the build to timeout. If set to None, will be 10 minutes. If
99
-
# unset, will default to 3 hours. This time should be less than the SREGISTRY_GOOGLE_BUILD_EXPIRE_SECONDS
99
+
# unset, will default to 3 hours. This time should be less than the GOOGLE_BUILD_EXPIRE_SECONDS
100
100
101
-
# SREGISTRY_GOOGLE_BUILD_EXPIRE_SECONDS=28800
101
+
# GOOGLE_BUILD_EXPIRE_SECONDS=28800
102
102
# The number of seconds for the build to expire, meaning it's response is no longer accepted by the server. This must be defined.
103
103
# The default 28800 indicates 8 hours (in seconds)
0 commit comments