From 42f79a5ce010f5fddeb43d4f49958b77e79bb654 Mon Sep 17 00:00:00 2001 From: RomanPorshnev Date: Sat, 21 Dec 2024 04:30:52 +0300 Subject: [PATCH] add volumes --- .env | 2 -- backend/Dockerfile | 4 +++- backend/app.py | 7 ++++--- backend/{ => db}/import_data.json | 0 backend/{ => db}/toponyms_data.json | 0 docker-compose.yml | 5 +++-- 6 files changed, 10 insertions(+), 8 deletions(-) rename backend/{ => db}/import_data.json (100%) rename backend/{ => db}/toponyms_data.json (100%) diff --git a/.env b/.env index 9e8bf7e..4549916 100644 --- a/.env +++ b/.env @@ -1,3 +1 @@ -NEO4J_USER=neo4j -NEO4J_PASSWORD=12345678 NEO4J_AUTH=neo4j/12345678 \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile index 79e7eb6..1e2abf7 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -5,7 +5,9 @@ WORKDIR /app COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt -COPY . . +COPY app.py /app/app.py + +VOLUME ["/app/db"] ENV NEO4J_URI=bolt://neo4j:7687 ENV NEO4J_USER=neo4j diff --git a/backend/app.py b/backend/app.py index d4cf6cb..ad3c39a 100644 --- a/backend/app.py +++ b/backend/app.py @@ -9,8 +9,9 @@ import os uri = os.getenv("NEO4J_URI", "bolt://neo4j:7687") -username = os.getenv("NEO4J_USER", "neo4j") -password = os.getenv("NEO4J_PASSWORD", "12345678") +auth = os.getenv("NEO4J_AUTH", "neo4j/12345678").split('/') +username = auth[0] +password = auth[1] driver = GraphDatabase.driver(uri, auth=(username, password)) @@ -384,5 +385,5 @@ def export_data(): if __name__ == "__main__": clear_database() - import_toponyms("toponyms_data.json") + import_toponyms("db/toponyms_data.json") app.run(debug=True, port=5001, host='0.0.0.0') diff --git a/backend/import_data.json b/backend/db/import_data.json similarity index 100% rename from backend/import_data.json rename to backend/db/import_data.json diff --git a/backend/toponyms_data.json b/backend/db/toponyms_data.json similarity index 100% rename from backend/toponyms_data.json rename to backend/db/toponyms_data.json diff --git a/docker-compose.yml b/docker-compose.yml index be61067..f79dbb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,8 +22,9 @@ services: ports: - "127.0.0.1:5001:5001" environment: - - NEO4J_USER=${NEO4J_USER} - - NEO4J_PASSWORD=${NEO4J_PASSWORD} + NEO4J_AUTH: ${NEO4J_AUTH} + volumes: + - ./backend/db:/app/db depends_on: db: condition: service_healthy