Skip to content

Commit

Permalink
Merge pull request #63 from codex-team/add-docker-sample
Browse files Browse the repository at this point in the history
Add docker sample
  • Loading branch information
n0str authored Oct 19, 2023
2 parents bef9dfa + d9de965 commit e29e3fd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
37 changes: 33 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# Development

## Running in development mode
## Setup local database

You can install PostgreSQL local https://www.postgresql.org/download/ or use Docker (see `postgres.yml`):
```
version: "3.2"
services:
postgres:
image: postgres
environment:
POSTGRES_PASSWORD: example
ports:
- 127.0.0.1:5432:5432
volumes:
- ./database:/var/lib/postgresql/data
```

To run it execute: `docker compose -f postgres.yml up -d` where `-d` is used for background run.
If you have outdated version of docker, try use `docker-compose` instead of `docker compose` (https://docs.docker.com/compose/)

## Running application in development mode

To run application in development mode you need to run `npm run dev` command.
It will start application with `nodemon` and restart it on any changes in source code.
Expand All @@ -9,18 +28,28 @@ You can try to build and run it in local Docker:
```
version: "3.2"
services:
api:
api:
build:
dockerfile: Dockerfile
context: .
ports:
- "127.0.0.1:3000:3000"
volumes:
- ./app-config.yaml:/usr/app/app-config.yaml
restart: unless-stopped
```

## Configuration

Default application configuration is stored in `app-config.yaml` file.
To override default configuration you can create `app-config.local.yaml` file and override any configuration value.
Default application configuration is stored in `app-config.yaml` file. This file is intended for docker configuration since it's using `dsn: 'postgres://postgres:example@postgres:5432/codex-notes'`.

To override default configuration you can create `app-config.local.yaml` file and override any configuration value locally.
You can also override settings in docker by overriding `app-config.local.yaml` via volumes:
```
volumes:
- ./app-config.yaml:/usr/app/app-config.yaml
- ./app-config.local.yaml:/usr/app/app-config.local.yaml
```

## Logging

Expand Down
2 changes: 1 addition & 1 deletion app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ logging:
database: info

database:
dsn: 'postgres://postgres:pass@localhost:5432/codex-notes'
dsn: 'postgres://postgres:example@postgres:5432/codex-notes'

openai:
token: 'token'
Expand Down
10 changes: 10 additions & 0 deletions postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.2"
services:
postgres:
image: postgres
environment:
POSTGRES_PASSWORD: pass
ports:
- 127.0.0.1:5432:5432
volumes:
- ./database:/var/lib/postgresql/data

0 comments on commit e29e3fd

Please sign in to comment.