Skip to content

Commit

Permalink
Add environment variables for Redis and Postgres hosts (#1641)
Browse files Browse the repository at this point in the history
* Update to support additional env vars

- Added environment variables for:
  - Redis Host
  - Postgres Host
- Change `POSTGRES_PASSWORD` => `CVAT_POSTGRES_PASSWORD` to avoid collision with other scripts.

* Using ENV vars in supervisord.conf

* Fixing ENV vars.

* add env vars to docker-compose.yml

* merge supervisord.conf

* update docker-compose env var values

* Update CHANGELOG.md

Co-authored-by: Aleksandr Melnikov <aleksandr@onepanel.io>
Co-authored-by: Nikita Manovich <40690625+nmanovic@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 5, 2020
1 parent 306e91c commit 3cb1f52
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Throttling policy for unauthenticated users (<https://github.com/opencv/cvat/pull/1531>)
- Added default label color table for mask export (https://github.com/opencv/cvat/pull/1549)
- Added environment variables for Redis and Postgres hosts for Kubernetes deployment support (<https://github.com/opencv/cvat/pull/1641>)
- Added visual identification for unavailable formats (https://github.com/opencv/cvat/pull/1567)

### Changed
Expand Down
8 changes: 4 additions & 4 deletions cvat/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
]

for key in RQ_QUEUES:
RQ_QUEUES[key]['HOST'] = 'cvat_redis'
RQ_QUEUES[key]['HOST'] = os.getenv('CVAT_REDIS_HOST', 'cvat_redis')

CACHEOPS_REDIS['host'] = 'cvat_redis'
CACHEOPS_REDIS['host'] = os.getenv('CVAT_REDIS_HOST', 'cvat_redis')

# Django-sendfile:
# https://github.com/johnsensible/django-sendfile
Expand All @@ -25,9 +25,9 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': 'cvat_db',
'HOST': os.getenv('CVAT_POSTGRES_HOST', 'cvat_db'),
'NAME': 'cvat',
'USER': 'root',
'PASSWORD': os.getenv('POSTGRES_PASSWORD', ''),
'PASSWORD': os.getenv('CVAT_POSTGRES_PASSWORD', ''),
}
}
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ services:
environment:
DJANGO_MODWSGI_EXTRA_ARGS: ""
ALLOWED_HOSTS: '*'
CVAT_REDIS_HOST: "cvat_redis"
CVAT_POSTGRES_HOST: "cvat_db"
volumes:
- cvat_data:/home/django/data
- cvat_keys:/home/django/keys
Expand Down
10 changes: 5 additions & 5 deletions supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ priority=1
autorestart=true

[program:rqworker_default]
command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \
"exec /usr/bin/python3 %(ENV_HOME)s/manage.py rqworker -v 3 default"
environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock"
numprocs=2
process_name=rqworker_default_%(process_num)s

[program:rqworker_low]
command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \
"exec /usr/bin/python3 %(ENV_HOME)s/manage.py rqworker -v 3 low"
environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock"
numprocs=1

[program:git_status_updater]
command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \
"/usr/bin/python3 ~/manage.py update_git_states"
environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock"
numprocs=1

[program:rqscheduler]
command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \
"/usr/bin/python3 /usr/local/bin/rqscheduler --host redis -i 30"
environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock"
numprocs=1
Expand All @@ -53,7 +53,7 @@ numprocs=1
; apps are dynamically loaded by an environment variable. It can lead to issues
; with docker cache. Thus it is necessary to run collectstatic here for such
; apps.
command=%(ENV_HOME)s/wait-for-it.sh db:5432 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_POSTGRES_HOST)s:5432 -t 0 -- bash -ic \
"rm -f /tmp/cvat-server/httpd.pid && /usr/bin/python3 ~/manage.py migrate && \
/usr/bin/python3 ~/manage.py collectstatic --no-input && \
exec /usr/bin/python3 $HOME/manage.py runmodwsgi --log-to-terminal --port 8080 \
Expand Down

0 comments on commit 3cb1f52

Please sign in to comment.