Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.azure
.azure
.venv
32 changes: 31 additions & 1 deletion src/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ Requirements:

- Python (3.8+)

**Recommended:** Install a Python [venv](https://docs.python.org/3/library/venv.html)

```bash
$ python3 -m venv .venv
$ . .venv/bin/activate
```

```bash
$ pip install -r requirements.txt
$ pip install -r src/api/requirements.txt
```

Or
Expand All @@ -16,6 +23,29 @@ Or
$ poetry install
```

## Running with DocumentDB on local host

Start the DoucmentDB Docker image:

```bash
$ docker run -dt -p 10260:10260 ghcr.io/microsoft/documentdb/documentdb-local:latest
```
**Note:** Check TBD for more configuration parameters

Then set the `AZURE_COSMOS_CONNECTION_STRING` to the following value:
```bash
export AZURE_COSMOS_CONNECTION_STRING="mongodb://default_user:Admin100@localhost:10260/?directConnection=true&serverSelectionTimeoutMS=2000&authMechanism=SCRAM-SHA-256&tls=true&tlsAllowInvalidCertificates=true&appName=mongosh+2.5.0"
```

You might need to adjust the username `default_user` or the password `Admin100` or the port `10260` if you customized this
when starting the docker container.

There is also a docker-compose.file you cna use to run both containers. To do so:
```bash
$ docker-compose up
```
You then can access the todo application like noted in "Running in Docker"

## Running

Before running, set the `AZURE_COSMOS_CONNECTION_STRING` environment variable to the connection-string for mongo/cosmos.
Expand Down
36 changes: 36 additions & 0 deletions src/api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.8'

# to have custom username/passwd run `DOCUMENT_DB_USERNAME=my_custom_user DOCUMENT_DB_PASSWORD=my_secure_password docker-compose up`
services:
api:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:3100"
environment:
- AZURE_COSMOS_CONNECTION_STRING=mongodb://${DOCUMENT_DB_USERNAME:-todo_admin}:${DOCUMENT_DB_PASSWORD:-Admin100}@documentdb:10260/?directConnection=true&serverSelectionTimeoutMS=2000&authMechanism=SCRAM-SHA-256&tls=true&tlsAllowInvalidCertificates=true&appName=todo-app
- AZURE_COSMOS_DATABASE_NAME=todo_db
depends_on:
- documentdb
networks:
- todo-network

documentdb:
image: ghcr.io/microsoft/documentdb/documentdb-local:latest
ports:
- "10260:10260"
environment:
- USERNAME=${DOCUMENT_DB_USERNAME:-todo_admin}
- PASSWORD=${DOCUMENT_DB_PASSWORD:-Admin100}
networks:
- todo-network
volumes:
- documentdb-data:/data/db

networks:
todo-network:
driver: bridge

volumes:
documentdb-data: