Skip to content

Commit

Permalink
Merge pull request #60 from intuitem/improve/caddy-docker-compose
Browse files Browse the repository at this point in the history
Add caddy for docker-compose
  • Loading branch information
eric-intuitem authored Feb 21, 2024
2 parents bc5dc67 + f642048 commit cd3488a
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 288 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/startup-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ jobs:
docker compose exec backend /bin/bash -c "[email protected] DJANGO_SUPERUSER_PASSWORD=1234 python manage.py createsuperuser --noinput && exit 0"
- name: Run tests
working-directory: ${{ env.working-directory }}
run: npx playwright test tests/functional/startup.test.ts
- uses: actions/upload-artifact@v4
if: always()
with:
name: startup-docker-test-report
path: |
${{ env.working-directory }}/tests/reports/
${{ env.working-directory }}/tests/results/
retention-days: 5
run: |
response=$(curl -d "[email protected]&password=1234" -H "Origin: https://localhost:8443" https://localhost:8443/login -k)
server_reponse='{"type":"redirect","status":302,"location":"/analytics"}'
if [[ "$response" == "$server_reponse" ]]; then
echo "Success"
exit 0
else
echo "Failure"
exit 1
fi
24 changes: 3 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cd ciso-assistant-community

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

You can then reach CISO Assistant using your web brower at [http://localhost:3000/](http://localhost:3000/)
You can then reach CISO Assistant using your web brower at [https://localhost:8443/](https://localhost:8443/)

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

Expand Down Expand Up @@ -185,7 +185,6 @@ python manage.py migrate
python manage.py createsuperuser
```


8. Run development server.

```sh
Expand Down Expand Up @@ -236,26 +235,9 @@ npm install
npm run dev
```

5. If you want to setup Postgres:

- Launch one of these commands to enter in Postgres:
- ```psql as superadmin```
- ```sudo su postgres```
- ```psql```
- Create the database "mira"
- ```create database mira;```
- Create user "mirauser" and grant it access
- ```create user mirauser with password '<POSTGRES_PASSWORD>';```
- ```grant all privileges on database mira to mirauser;```

6. Prepare and apply migrations.

```sh
(venv)$ cd backend
(venv)$ pytest
```
5. Reach the frontend on http://localhost:5173

Coming soon.
Note: Safari will not properly work in this setup, as it requires https for secure cookies. The simplest solution is to use Chrome or Firefox. An alternative is to use a caddy proxy. This is the solution used in docker-compose, so you can use it as an example.

## Managing migrations

Expand Down
8 changes: 0 additions & 8 deletions backend/ciso_assistant/asgi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
"""
<<<<<<<< HEAD:backend/ciso_assistant/asgi.py
ASGI config for ciso_assistant project.
========
ASGI config for mira project.
>>>>>>>> main:mira/asgi.py
It exposes the ASGI callable as a module-level variable named ``application``.
Expand All @@ -15,10 +11,6 @@

from django.core.asgi import get_asgi_application

<<<<<<<< HEAD:backend/ciso_assistant/asgi.py
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ciso_assistant.settings")
========
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mira.settings')
>>>>>>>> main:mira/asgi.py

application = get_asgi_application()
2 changes: 1 addition & 1 deletion docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ else
docker compose exec backend python manage.py migrate
echo "initialize your superuser account..."
docker compose exec backend python manage.py createsuperuser
echo "connect to ciso assistant on http://localhost:3000"
echo "connect to ciso assistant on https://localhost:8443"
echo "for successive runs you can now use docker compose up"
fi
22 changes: 18 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,33 @@ services:
restart: always
environment:
- ALLOWED_HOSTS=backend
- CISO_ASSISTANT_URL=http://localhost:3000
- CISO_ASSISTANT_URL=https://localhost:8443
- DJANGO_DEBUG=True
volumes:
- ./db:/code/db

frontend:
container_name: frontend
environment:
- ORIGIN=http://localhost:3000
- PUBLIC_BACKEND_API_URL=http://backend:8000/api
- PROTOCOL_HEADER=x-forwarded-proto
- HOST_HEADER=x-forwarded-host
build: ./frontend
depends_on:
- backend
ports:
- 3000:3000

caddy:
container_name: caddy
image: caddy:2.7.6
restart: unless-stopped
ports:
- 8443:8443
command:
- caddy
- reverse-proxy
- --from
- https://localhost:8443
- --to
- frontend:3000
volumes:
- ./db:/data
Loading

0 comments on commit cd3488a

Please sign in to comment.