Skip to content

Commit

Permalink
Docker-compose improvements: redis / rqworker / wait for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
niconoe committed Jul 18, 2023
1 parent 76e1baa commit 3ed3a70
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
5 changes: 4 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ system.
3. Tweak this file as necessary (see comments in the file)
2. $ run docker-compose up (keep this terminal open, and open a second one for subsequent commands)
3. Create a first superuser (administrator):
$ docker-compose exec pterois poetry run python manage.py createsuperuser
$ docker-compose exec pterois poetry run python manage.py createsuperuser
4. Create a few species before running the first import (see below)
5. Run the first import:
6. $ docker-compose exec pterois poetry run python manage.py import_observations
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ See [INSTALL.md](INSTALL.md).
## Pterois instances in the wild

- [LIFE RIPARIAS Early Alert](https://alert.riparias.be) (Targets riparian invasive species in Belgium)
- [Pterois demo instance](https://pterois-demo.niconoe.eu/) (Always in sync with the `devel` branch of this repository)
- [Pterois demo instance](https://pterois-demo.niconoe.eu/) (Always in sync with the `devel` branch of this repository)

TODO next Docker:

- Polish documentation
- Add more steps (create species, run first import, etc.)
- Push images to dockerhub
4 changes: 2 additions & 2 deletions djangoproject/local_settings_docker.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
), # Languages available in the interface. Subset of the languages in `LANGUAGES`.
# A Gbif.org account is necessary to automatically download observations via the `import_observations` command
"GBIF_DOWNLOAD_CONFIG": {
"USERNAME": "niconoe2",
"PASSWORD": "ITAots!12",
"USERNAME": "aaaa",
"PASSWORD": "bbbb",
"COUNTRY_CODE": "BE", # Only download observations from this country
"MINIMUM_YEAR": 2000, # Observations must be from this year or later
},
Expand Down
8 changes: 5 additions & 3 deletions djangoproject/local_settings_docker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
# Redis configuration for django-rq
RQ_QUEUES = {
"default": {
"HOST": "localhost",
"HOST": "redis",
"PORT": 6379,
"DB": 0,
# "PASSWORD": "some-password",
"DEFAULT_TIMEOUT": 360,
},
}

ALLOWED_HOSTS = ["0.0.0.0", "localhost"]

STATIC_URL = "/static/"
STATIC_ROOT = BASE_DIR / "staticfiles"
STATIC_ROOT = BASE_DIR / "staticfiles"

CSRF_TRUSTED_ORIGINS = ["http://localhost:1337"]
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
30 changes: 28 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version: '3'
# TODO: add/configure Redis

services:
nginx:
Expand All @@ -18,12 +17,39 @@ services:
- POSTGRES_PASSWORD=pteroisdb
- POSTGRES_USER=pteroisdb
- POSTGRES_DB=pteroisdb
healthcheck:
test: ['CMD-SHELL', 'psql -h localhost -U $${POSTGRES_USER} -c select 1 -d $${POSTGRES_DB}']
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7.0.12
expose:
- 6379
pterois:
image : pterois:1.0
expose:
- 8000
depends_on:
- db
db:
condition: service_healthy
redis:
condition: service_started

volumes:
- static_volume:/app/staticfiles
- type: bind
source: ./local_settings_docker.py
target: /app/djangoproject/local_settings_docker.py
read_only: true
rqworker:
image: pterois:1.0
entrypoint: poetry run python manage.py rqworker default
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
volumes:
- static_volume:/app/staticfiles
- type: bind
Expand Down

0 comments on commit 3ed3a70

Please sign in to comment.