diff --git a/Dockerfile b/Dockerfile index 49ae2e45d..148df0dfe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,50 +1,29 @@ -FROM python:3.11 +FROM python:3.11-slim # Set build argument ARG DEBUG -ARG API_ENABLED # Set environment variable based on the build argument ENV DEBUG=${DEBUG} -ENV API_ENABLED=${API_ENABLED} ENV PIP_NO_CACHE_DIR=true ENV PATH="${PATH}:/root/.poetry/bin" -RUN pip install poetry - WORKDIR /app COPY pyproject.toml poetry.lock /app/ +RUN pip install poetry + +# Create virtualenv +RUN poetry config virtualenvs.create false + # Install the dependencies -RUN poetry config virtualenvs.create false && \ - poetry install --no-root --no-dev - -RUN apt-get update -q && \ - apt-get install -y -q \ - gcc \ - python3-dev \ - curl \ - zip \ - jq \ - netcat-traditional && \ - pip install poetry && \ - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ - unzip -qq awscliv2.zip && \ - ./aws/install && \ - apt-get clean && \ - rm -rf \ - awscliv2.zip \ - /var/lib/apt/lists/* \ - /tmp/* \ - /var/tmp/* - -WORKDIR /app +RUN poetry install --no-root --no-dev + # Set the PYTHONPATH environment variable to include the /app directory ENV PYTHONPATH=/app COPY cognee/ /app/cognee - COPY entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh diff --git a/Dockerfile-old b/Dockerfile-old new file mode 100644 index 000000000..5913ac543 --- /dev/null +++ b/Dockerfile-old @@ -0,0 +1,49 @@ +FROM python:3.11 + +# Set build argument +ARG DEBUG + +# Set environment variable based on the build argument +ENV DEBUG=${DEBUG} +ENV PIP_NO_CACHE_DIR=true +ENV PATH="${PATH}:/root/.poetry/bin" + +RUN pip install poetry + +WORKDIR /app +COPY pyproject.toml poetry.lock /app/ + +# Install the dependencies +RUN poetry config virtualenvs.create false && \ + poetry install --no-root --no-dev + +RUN apt-get update -q && \ + apt-get install -y -q \ + gcc \ + python3-dev \ + curl \ + zip \ + jq \ + netcat-traditional && \ + pip install poetry && \ + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ + unzip -qq awscliv2.zip && \ + ./aws/install && \ + apt-get clean && \ + rm -rf \ + awscliv2.zip \ + /var/lib/apt/lists/* \ + /tmp/* \ + /var/tmp/* + +WORKDIR /app +# Set the PYTHONPATH environment variable to include the /app directory +ENV PYTHONPATH=/app + +COPY cognee/ /app/cognee + + +COPY entrypoint.sh /app/entrypoint.sh +RUN chmod +x /app/entrypoint.sh + +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/Dockerfile-vanilla b/Dockerfile-vanilla deleted file mode 100644 index 30a2019dc..000000000 --- a/Dockerfile-vanilla +++ /dev/null @@ -1,30 +0,0 @@ -FROM python:3.11-slim - -# Set build argument -ARG DEBUG - -# Set environment variable based on the build argument -ENV DEBUG=${DEBUG} -ENV PIP_NO_CACHE_DIR=true -ENV PATH="${PATH}:/root/.poetry/bin" - -WORKDIR /app -COPY pyproject.toml poetry.lock /app/ - -RUN pip install poetry - -# Create virtualenv -RUN poetry config virtualenvs.create false - -# Install the dependencies -RUN poetry install --no-root --no-dev - -# Set the PYTHONPATH environment variable to include the /app directory -ENV PYTHONPATH=/app - -COPY cognee/ /app/cognee - -COPY entrypoint-vanilla.sh /app/entrypoint-vanilla.sh -RUN chmod +x /app/entrypoint-vanilla.sh - -ENTRYPOINT ["/app/entrypoint-vanilla.sh"] diff --git a/cognee-frontend/.dockerignore b/cognee-frontend/.dockerignore new file mode 100644 index 000000000..f74c78183 --- /dev/null +++ b/cognee-frontend/.dockerignore @@ -0,0 +1,2 @@ +.next +node_modules diff --git a/cognee-frontend/Dockerfile b/cognee-frontend/Dockerfile index 0a3775dc8..26f479f88 100644 --- a/cognee-frontend/Dockerfile +++ b/cognee-frontend/Dockerfile @@ -1,20 +1,20 @@ # Use an official Node.js runtime as a parent image -FROM node:18.17.0 +FROM node:18-alpine # Set the working directory to /app WORKDIR /app # Copy package.json and package-lock.json to the working directory -COPY package*.json ./ +COPY package.json package-lock.json ./ # Install any needed packages specified in package.json -RUN npm install +RUN npm ci # Copy the rest of the application code to the working directory -COPY . . - -# Make port 3000 available to the world outside this container -EXPOSE 3000 +COPY src ./src +COPY public ./public +COPY next.config.mjs . +COPY tsconfig.json . # Build the app and run it -CMD ["sh", "-c", "npm run dev"] +CMD npm run dev diff --git a/docker-compose-vanilla.yml b/docker-compose-vanilla.yml index 7a79e622b..07bae272d 100644 --- a/docker-compose-vanilla.yml +++ b/docker-compose-vanilla.yml @@ -5,21 +5,21 @@ services: - cognee-network build: context: . - dockerfile: Dockerfile-vanilla + dockerfile: Dockerfile volumes: - .:/app - - /app/cognee-frontend/ + - /app/cognee-frontend/ # Ignore frontend code environment: - HOST=0.0.0.0 - ENVIRONMENT=local - PYTHONPATH=. ports: - 8000:8000 - - 5678:5678 # Debugging + # - 5678:5678 # Debugging deploy: resources: limits: - cpus: "4.0" + cpus: 4.0 memory: 8GB frontend: @@ -28,9 +28,11 @@ services: context: ./cognee-frontend dockerfile: Dockerfile volumes: - - "./cognee-frontend:/app" + - ./cognee-frontend/src:/app/src + - ./cognee-frontend/public:/app/public ports: - - "3000:3000" + - 3000:3000 + # - 9229:9229 # Debugging networks: - cognee-network diff --git a/docker-compose.yml b/docker-compose.yml index d706d0316..a23630091 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,45 +1,25 @@ -version: "3.9" - services: - neo4j: - image: neo4j:latest - container_name: neo4j - ports: - - "7474:7474" - - "7687:7687" - environment: - - NEO4J_AUTH=neo4j/pleaseletmein - - NEO4J_PLUGINS=["apoc"] - networks: - - cognee_backend - cognee: container_name: cognee networks: - - cognee_backend + - cognee-network build: - context: ./ + context: . + dockerfile: Dockerfile volumes: - - "./:/app" - - ./.data:/app/.data + - .:/app + - /app/cognee-frontend/ # Ignore frontend code environment: - HOST=0.0.0.0 - ENVIRONMENT=local - PYTHONPATH=. ports: - 8000:8000 - - 443:443 - - 80:80 - - 50051:50051 - - 5678:5678 # Debugging - depends_on: - - postgres - - neo4j - - frontend + # - 5678:5678 # Debugging deploy: resources: limits: - cpus: "4.0" + cpus: 4.0 memory: 8GB frontend: @@ -48,36 +28,40 @@ services: context: ./cognee-frontend dockerfile: Dockerfile volumes: - - "./cognee-frontend:/app" + - ./cognee-frontend/src:/app/src + - ./cognee-frontend/public:/app/public ports: - - "3000:3000" + - 3000:3000 + # - 9229:9229 # Debugging networks: - - cognee_backend + - cognee-network - postgres: - image: postgres - container_name: postgres - environment: - - POSTGRES_HOST_AUTH_METHOD=trust - - POSTGRES_USER=bla - - POSTGRES_PASSWORD=bla - - POSTGRES_DB=bubu - - networks: - - cognee_backend - ports: - - "5432:5432" + neo4j: + image: neo4j:latest + container_name: neo4j + profiles: + - neo4j + ports: + - 7474:7474 + - 7687:7687 + environment: + - NEO4J_AUTH=neo4j/pleaseletmein + - NEO4J_PLUGINS=["apoc"] + networks: + - cognee-network falkordb: image: falkordb/falkordb:edge container_name: falkordb + profiles: + - falkordb ports: - - "6379:6379" - - "3001:3000" + - 6379:6379 + - 3001:3000 networks: - - cognee_backend + - cognee-network networks: - cognee_backend: - name: cognee_backend + cognee-network: + name: cognee-network diff --git a/entrypoint-old.sh b/entrypoint-old.sh new file mode 100755 index 000000000..8d8053759 --- /dev/null +++ b/entrypoint-old.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# export ENVIRONMENT + +echo "Debug mode: $DEBUG" +echo "Environment: $ENVIRONMENT" + +if [ "$ENVIRONMENT" != "local" ]; then + echo "Running fetch_secret.py" + + PYTHONPATH=. python cognee/fetch_secret.py + + if [ $? -ne 0 ]; then + echo "Error: fetch_secret.py failed" + exit 1 + fi +else + echo '"local" environment is active, skipping fetch_secret.py' +fi + +echo "Creating database..." +# +#PYTHONPATH=. python cognee/setup_database.py +#if [ $? -ne 0 ]; then +# echo "Error: setup_database.py failed" +# exit 1 +#fi + +echo "Starting Gunicorn" + +if [ "$DEBUG" = true ]; then + echo "Waiting for the debugger to attach..." + python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --bind=0.0.0.0:443 --log-level debug cognee.api.client:app +else + gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --bind=0.0.0.0:443 --log-level debug cognee.api.client:app +fi diff --git a/entrypoint-vanilla.sh b/entrypoint-vanilla.sh deleted file mode 100755 index ed8b4780a..000000000 --- a/entrypoint-vanilla.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -echo "Debug mode: $DEBUG" -echo "Environment: $ENVIRONMENT" - -echo "Starting Gunicorn" - -if [ "$ENVIRONMENT" = "local" ]; then - if [ "$DEBUG" = true ]; then - echo "Waiting for the debugger to attach..." - - python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level debug --reload cognee.api.client:app - else - gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level debug --reload cognee.api.client:app - fi -else - gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level error cognee.api.client:app -fi diff --git a/entrypoint.sh b/entrypoint.sh index 8d8053759..ed8b4780a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,35 +1,18 @@ #!/bin/bash -# export ENVIRONMENT echo "Debug mode: $DEBUG" echo "Environment: $ENVIRONMENT" -if [ "$ENVIRONMENT" != "local" ]; then - echo "Running fetch_secret.py" - - PYTHONPATH=. python cognee/fetch_secret.py - - if [ $? -ne 0 ]; then - echo "Error: fetch_secret.py failed" - exit 1 - fi -else - echo '"local" environment is active, skipping fetch_secret.py' -fi - -echo "Creating database..." -# -#PYTHONPATH=. python cognee/setup_database.py -#if [ $? -ne 0 ]; then -# echo "Error: setup_database.py failed" -# exit 1 -#fi - echo "Starting Gunicorn" -if [ "$DEBUG" = true ]; then - echo "Waiting for the debugger to attach..." - python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --bind=0.0.0.0:443 --log-level debug cognee.api.client:app +if [ "$ENVIRONMENT" = "local" ]; then + if [ "$DEBUG" = true ]; then + echo "Waiting for the debugger to attach..." + + python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level debug --reload cognee.api.client:app + else + gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level debug --reload cognee.api.client:app + fi else - gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --bind=0.0.0.0:443 --log-level debug cognee.api.client:app + gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level error cognee.api.client:app fi