Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed Database to MongoDB and Updated docker-compose for MongoDB Integration #68

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . /app/backend

EXPOSE 8000
#RUN python manage.py migrate
#RUN python manage.py makemigrations
# RUN python manage.py migrate
# RUN python manage.py makemigrations
6 changes: 6 additions & 0 deletions data/mongodb/.mongodb/mongosh/67a9e746372a239bce544ca6_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"t":{"$date":"2025-02-10T11:47:18.691Z"},"s":"I","c":"MONGOSH","id":1000000000,"ctx":"log","msg":"Starting log","attr":{"execPath":"/usr/bin/mongosh","envInfo":{"EDITOR":null,"NODE_OPTIONS":null,"TERM":null},"version":"2.3.8","distributionKind":"compiled","buildArch":"x64","buildPlatform":"linux","buildTarget":"linux-x64","buildTime":"2024-12-30T22:43:03.083Z","gitVersion":"0f0681f5ed67530071c9b3811cf5e18a222b9ae4","nodeVersion":"v20.18.1","opensslVersion":"3.0.15+quic","sharedOpenssl":false,"runtimeArch":"x64","runtimePlatform":"linux","runtimeGlibcVersion":"2.39","deps":{"nodeDriverVersion":"6.12.0","libmongocryptVersion":"1.11.0","libmongocryptNodeBindingsVersion":"6.1.0","kerberosVersion":"2.1.0"}}}
{"t":{"$date":"2025-02-10T11:47:18.791Z"},"s":"I","c":"MONGOSH","id":1000000048,"ctx":"config","msg":"Loading global configuration file","attr":{"filename":"/etc/mongosh.conf","found":false}}
{"t":{"$date":"2025-02-10T11:47:19.098Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000049,"ctx":"mongosh-connect","msg":"Loaded system CA list","attr":{"caCount":293,"asyncFallbackError":null,"systemCertsError":null,"messages":[]}}
{"t":{"$date":"2025-02-10T11:47:19.121Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000042,"ctx":"mongosh-connect","msg":"Initiating connection attempt","attr":{"uri":"mongodb://127.0.0.1:27017/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.8","driver":{"name":"nodejs|mongosh","version":"6.12.0|2.3.8"},"devtoolsConnectVersion":"3.3.4","host":"127.0.0.1:27017"}}
{"t":{"$date":"2025-02-10T11:47:19.151Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000035,"ctx":"mongosh-connect","msg":"Server heartbeat succeeded","attr":{"connectionId":"127.0.0.1:27017"}}
{"t":{"$date":"2025-02-10T11:47:19.248Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000037,"ctx":"mongosh-connect","msg":"Connection attempt finished"}
15 changes: 15 additions & 0 deletions data/mongodb/.mongodb/mongosh/67a9e7477dc39f8029544ca6_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{"t":{"$date":"2025-02-10T11:47:19.614Z"},"s":"I","c":"MONGOSH","id":1000000000,"ctx":"log","msg":"Starting log","attr":{"execPath":"/usr/bin/mongosh","envInfo":{"EDITOR":null,"NODE_OPTIONS":null,"TERM":null},"version":"2.3.8","distributionKind":"compiled","buildArch":"x64","buildPlatform":"linux","buildTarget":"linux-x64","buildTime":"2024-12-30T22:43:03.083Z","gitVersion":"0f0681f5ed67530071c9b3811cf5e18a222b9ae4","nodeVersion":"v20.18.1","opensslVersion":"3.0.15+quic","sharedOpenssl":false,"runtimeArch":"x64","runtimePlatform":"linux","runtimeGlibcVersion":"2.39","deps":{"nodeDriverVersion":"6.12.0","libmongocryptVersion":"1.11.0","libmongocryptNodeBindingsVersion":"6.1.0","kerberosVersion":"2.1.0"}}}
{"t":{"$date":"2025-02-10T11:47:19.662Z"},"s":"I","c":"MONGOSH","id":1000000005,"ctx":"config","msg":"User updated"}
{"t":{"$date":"2025-02-10T11:47:19.665Z"},"s":"I","c":"MONGOSH","id":1000000048,"ctx":"config","msg":"Loading global configuration file","attr":{"filename":"/etc/mongosh.conf","found":false}}
{"t":{"$date":"2025-02-10T11:47:19.742Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000049,"ctx":"mongosh-connect","msg":"Loaded system CA list","attr":{"caCount":293,"asyncFallbackError":null,"systemCertsError":null,"messages":[]}}
{"t":{"$date":"2025-02-10T11:47:19.763Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000042,"ctx":"mongosh-connect","msg":"Initiating connection attempt","attr":{"uri":"mongodb://127.0.0.1:27017/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.8","driver":{"name":"nodejs|mongosh","version":"6.12.0|2.3.8"},"devtoolsConnectVersion":"3.3.4","host":"127.0.0.1:27017"}}
{"t":{"$date":"2025-02-10T11:47:19.772Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000035,"ctx":"mongosh-connect","msg":"Server heartbeat succeeded","attr":{"connectionId":"127.0.0.1:27017"}}
{"t":{"$date":"2025-02-10T11:47:19.826Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000037,"ctx":"mongosh-connect","msg":"Connection attempt finished"}
{"t":{"$date":"2025-02-10T11:47:19.846Z"},"s":"I","c":"MONGOSH","id":1000000010,"ctx":"shell-api","msg":"Initialized context","attr":{"method":"setCtx","arguments":{}}}
{"t":{"$date":"2025-02-10T11:47:19.848Z"},"s":"I","c":"MONGOSH-SNIPPETS","id":1000000024,"ctx":"snippets","msg":"Fetching snippet index","attr":{"refreshMode":"allow-cached"}}
{"t":{"$date":"2025-02-10T11:47:19.850Z"},"s":"I","c":"MONGOSH-SNIPPETS","id":1000000019,"ctx":"snippets","msg":"Loaded snippets","attr":{"installdir":"/data/db/.mongodb/mongosh/snippets"}}
{"t":{"$date":"2025-02-10T11:47:19.969Z"},"s":"I","c":"MONGOSH-SNIPPETS","id":1000000028,"ctx":"snippets","msg":"Modifying snippets package.json failed","attr":{"error":"ENOENT: no such file or directory, open '/data/db/.mongodb/mongosh/snippets/package.json'"}}
{"t":{"$date":"2025-02-10T11:47:19.970Z"},"s":"I","c":"MONGOSH","id":1000000002,"ctx":"repl","msg":"Started REPL","attr":{"version":"2.3.8"}}
{"t":{"$date":"2025-02-10T11:47:19.985Z"},"s":"I","c":"MONGOSH","id":1000000004,"ctx":"connect","msg":"Connecting to server","attr":{"userId":null,"telemetryAnonymousId":"67a9e746372a239bce544ca5","connectionUri":"mongodb://<ip address>:27017/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.8","mongosh_version":"2.3.8","session_id":"67a9e7477dc39f8029544ca6","is_localhost":true,"is_do_url":false,"is_atlas_url":false,"is_atlas":false,"server_version":"8.0.4","node_version":"v20.18.1","server_os":"linux","server_arch":"x86_64","is_enterprise":false,"auth_type":null,"is_data_federation":false,"is_stream":false,"dl_version":null,"atlas_version":null,"is_genuine":true,"non_genuine_server_name":"mongodb","is_local_atlas":false,"fcv":"8.0","api_version":null,"api_strict":null,"api_deprecation_errors":null,"atlas_hostname":null}}
{"t":{"$date":"2025-02-10T11:47:20.220Z"},"s":"I","c":"MONGOSH","id":1000000011,"ctx":"shell-api","msg":"Performed API call","attr":{"method":"createUser","class":"Database","db":"admin","arguments":{}}}
{"t":{"$date":"2025-02-10T11:47:20.452Z"},"s":"I","c":"MONGOSH","id":1000000045,"ctx":"analytics","msg":"Flushed outstanding data","attr":{"flushError":"Trying to persist throttle state before userId is set","flushDuration":0}}
11 changes: 11 additions & 0 deletions data/mongodb/.mongodb/mongosh/67a9e74f3a45b9f77a544ca6_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{"t":{"$date":"2025-02-10T11:47:27.550Z"},"s":"I","c":"MONGOSH","id":1000000000,"ctx":"log","msg":"Starting log","attr":{"execPath":"/usr/bin/mongosh","envInfo":{"EDITOR":null,"NODE_OPTIONS":null,"TERM":null},"version":"2.3.8","distributionKind":"compiled","buildArch":"x64","buildPlatform":"linux","buildTarget":"linux-x64","buildTime":"2024-12-30T22:43:03.083Z","gitVersion":"0f0681f5ed67530071c9b3811cf5e18a222b9ae4","nodeVersion":"v20.18.1","opensslVersion":"3.0.15+quic","sharedOpenssl":false,"runtimeArch":"x64","runtimePlatform":"linux","runtimeGlibcVersion":"2.39","deps":{"nodeDriverVersion":"6.12.0","libmongocryptVersion":"1.11.0","libmongocryptNodeBindingsVersion":"6.1.0","kerberosVersion":"2.1.0"}}}
{"t":{"$date":"2025-02-10T11:47:27.599Z"},"s":"I","c":"MONGOSH","id":1000000005,"ctx":"config","msg":"User updated"}
{"t":{"$date":"2025-02-10T11:47:27.600Z"},"s":"I","c":"MONGOSH","id":1000000048,"ctx":"config","msg":"Loading global configuration file","attr":{"filename":"/etc/mongosh.conf","found":false}}
{"t":{"$date":"2025-02-10T11:47:27.683Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000049,"ctx":"mongosh-connect","msg":"Loaded system CA list","attr":{"caCount":293,"asyncFallbackError":null,"systemCertsError":null,"messages":[]}}
{"t":{"$date":"2025-02-10T11:47:27.707Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000042,"ctx":"mongosh-connect","msg":"Initiating connection attempt","attr":{"uri":"mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.8","driver":{"name":"nodejs|mongosh","version":"6.12.0|2.3.8"},"devtoolsConnectVersion":"3.3.4","host":"127.0.0.1:27017"}}
{"t":{"$date":"2025-02-10T11:47:27.718Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000035,"ctx":"mongosh-connect","msg":"Server heartbeat succeeded","attr":{"connectionId":"127.0.0.1:27017"}}
{"t":{"$date":"2025-02-10T11:47:27.805Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000037,"ctx":"mongosh-connect","msg":"Connection attempt finished"}
{"t":{"$date":"2025-02-10T11:47:27.808Z"},"s":"I","c":"MONGOSH","id":1000000010,"ctx":"shell-api","msg":"Initialized context","attr":{"method":"setCtx","arguments":{}}}
{"t":{"$date":"2025-02-10T11:47:27.814Z"},"s":"I","c":"MONGOSH-SNIPPETS","id":1000000019,"ctx":"snippets","msg":"Loaded snippets","attr":{"installdir":"/data/db/.mongodb/mongosh/snippets"}}
{"t":{"$date":"2025-02-10T11:47:27.819Z"},"s":"I","c":"MONGOSH","id":1000000003,"ctx":"repl","msg":"Start loading CLI scripts"}
{"t":{"$date":"2025-02-10T11:47:27.824Z"},"s":"I","c":"MONGOSH","id":1000000013,"ctx":"repl","msg":"Evaluating script passed on the command line"}
1 change: 1 addition & 0 deletions data/mongodb/.mongodb/mongosh/config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"userId":"67a9e746372a239bce544ca5","telemetryAnonymousId":"67a9e746372a239bce544ca5","enableTelemetry":true}
Empty file.
1 change: 1 addition & 0 deletions data/mongodb/.mongodb/mongosh/snippets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 2 additions & 0 deletions data/mongodb/WiredTiger
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WiredTiger
WiredTiger 11.3.0: (November 16, 2023)
1 change: 1 addition & 0 deletions data/mongodb/WiredTiger.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WiredTiger lock file
6 changes: 6 additions & 0 deletions data/mongodb/WiredTiger.turtle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
WiredTiger version string
WiredTiger 11.3.0: (November 16, 2023)
WiredTiger version
major=11,minor=3,patch=0
file:WiredTiger.wt
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=0),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.4=(addr="018381e4c3a51c7e8481e45cf562698581e4d9340356808080e3014fc0e23fc0",order=4,time=1739188043,size=28672,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=1,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=11,run_write_gen=9)),checkpoint_backup_info=,checkpoint_lsn=(2,384)
Binary file added data/mongodb/WiredTiger.wt
Binary file not shown.
Binary file added data/mongodb/WiredTigerHS.wt
Binary file not shown.
Binary file added data/mongodb/_mdb_catalog.wt
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added data/mongodb/index-1-3545043312376694256.wt
Binary file not shown.
Binary file added data/mongodb/index-3-3545043312376694256.wt
Binary file not shown.
Binary file added data/mongodb/index-5-3545043312376694256.wt
Binary file not shown.
Binary file added data/mongodb/index-6-3545043312376694256.wt
Binary file not shown.
Binary file added data/mongodb/index-8-3545043312376694256.wt
Binary file not shown.
Binary file added data/mongodb/index-9-3545043312376694256.wt
Binary file not shown.
Binary file added data/mongodb/journal/WiredTigerLog.0000000002
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions data/mongodb/mongod.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Binary file added data/mongodb/sizeStorer.wt
Binary file not shown.
Binary file added data/mongodb/storage.bson
Binary file not shown.
17 changes: 9 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
env_file:
- ".env"
depends_on:
- db
- mongodb
restart: always
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/admin || exit 1"]
Expand All @@ -35,16 +35,17 @@ services:
networks:
- notes-app-nw

db:
image: mysql
container_name: "db_cont"
mongodb:
image: mongo
container_name: "mongodb_cont"
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=test_db
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
- MONGO_INITDB_DATABASE=test_db
volumes:
- ./data/mysql/db:/var/lib/mysql
- ./data/mongodb:/data/db
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"]
test: ["CMD", "mongosh", "--eval", "db.runCommand('ping').ok"]
interval: 10s
timeout: 5s
retries: 5
Expand Down
56 changes: 56 additions & 0 deletions docker-compose.yml_donot
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: "3.8"

services:
nginx:
build: ./nginx
image: nginx
container_name: "nginx_cont"
ports:
- "80:80"
restart: always
depends_on:
- django_app
networks:
- notes-app-nw

django_app:
build:
context: .
image: django_app
container_name: "django_cont"
ports:
- "8000:8000"
command: sh -c "python manage.py migrate --noinput && gunicorn notesapp.wsgi --bind 0.0.0.0:8000"
env_file:
- ".env"
depends_on:
- db
restart: always
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/admin || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- notes-app-nw

db:
image: mysql
container_name: "db_cont"
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=test_db
volumes:
- db_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"]
interval: 10s
timeout: 5s
retries: 5
start_period: 60s
networks:
- notes-app-nw

networks:
notes-app-nw: