Skip to content

Commit

Permalink
Add docker-compose configuration with pg database
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-intuitem committed Oct 22, 2023
1 parent 246f6cb commit 2e34599
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ ciso_assistant/build.json
*.sqlite3
db/django_secret_key
db/attachments/
db/data/
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ python manage.py collectstatic
python manage.py createsuperuser
```

5. Run CISO
5. Run CISO Assistant

```sh
python manage.py runserver
```
You can then reach CISO using your web brower at [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
You can then reach CISO Assistant using your web brower at [http://127.0.0.1:8000/](http://127.0.0.1:8000/)

#### Using Docker

Expand All @@ -127,7 +127,7 @@ docker run --rm -it --env CREATE_SUPERUSER=true -p 8000:8000 -v ./db:/code/db c

When asked for, enter your email and password for your superuser.

You can then reach CISO using your web brower at [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
You can then reach CISO Assistant using your web brower at [http://127.0.0.1:8000/](http://127.0.0.1:8000/)

For the following executions, simply run:

Expand All @@ -137,7 +137,21 @@ docker run --rm -p 8000:8000 -v ./db:/code/db ciso-assistant:$(<ciso_assistant/

⚠️ *WARNING*: If you're using WSL you'll need to activate *Systemd*. Check out this [topic](https://stackoverflow.com/questions/65400999/enable-systemd-in-wsl-2) to do it.

### How to set up CISO for development? ✍️

#### Using docker-compose with a Postgres database

Simply launch:
```sh
./docker-compose-pg.sh
```

When asked for, enter your email and password for your superuser.

You can then reach CISO Assistant using your web brower at [http://127.0.0.1:8000/](http://127.0.0.1:8000/)

For following executions, use "docker-compose up" directly.

### How to set up CISO Assistant for development? ✍️

1. Clone the repository.

Expand Down
11 changes: 11 additions & 0 deletions docker-compose-pg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env bash

if [ -d db/data ] ; then
echo "the database seems already created"
echo "you should launch docker-compose up -d"
else
POSTGRES_PASSWORD=`uuidgen` docker-compose up -d
echo "initialize your superuser account..."
docker-compose exec ciso-assistant python manage.py createsuperuser
echo "for successive runs you can now use docker compose up"
fi
42 changes: 42 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.5"
services:
ciso-assistant:
build: .
image: ciso-assistant:0.9.1
container_name: "ciso-assistant"
ports:
- "8000:8000"
depends_on:
postgres:
condition: service_healthy
environment:
DJANGO_DEBUG: "True"
CISO_URL: http://127.0.0.1:8000
POSTGRES_NAME: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
# CISO_SUPERUSER_EMAIL: [email protected]
EMAIL_HOST: your.mail.server
EMAIL_PORT: 1025
EMAIL_HOST_USER: ''
EMAIL_HOST_PASSWORD: ''
EMAIL_USE_TLS: "False"
EMAIL_USE_SSL: "False"
DEFAULT_FROM_EMAIL: [email protected]
DB_HOST: ciso-postgres
volumes:
- ./db:/code/db

postgres:
image: postgres
container_name: "ciso-postgres"
restart: always
environment:
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
volumes:
- ./db/data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

0 comments on commit 2e34599

Please sign in to comment.