fix: run frontend in a container
This commit is contained in:
parent
cb64ab14fa
commit
e23faccb6a
10 changed files with 151 additions and 165 deletions
37
Dockerfile
37
Dockerfile
|
|
@ -1,50 +1,29 @@
|
||||||
FROM python:3.11
|
FROM python:3.11-slim
|
||||||
|
|
||||||
# Set build argument
|
# Set build argument
|
||||||
ARG DEBUG
|
ARG DEBUG
|
||||||
ARG API_ENABLED
|
|
||||||
|
|
||||||
# Set environment variable based on the build argument
|
# Set environment variable based on the build argument
|
||||||
ENV DEBUG=${DEBUG}
|
ENV DEBUG=${DEBUG}
|
||||||
ENV API_ENABLED=${API_ENABLED}
|
|
||||||
ENV PIP_NO_CACHE_DIR=true
|
ENV PIP_NO_CACHE_DIR=true
|
||||||
ENV PATH="${PATH}:/root/.poetry/bin"
|
ENV PATH="${PATH}:/root/.poetry/bin"
|
||||||
|
|
||||||
RUN pip install poetry
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY pyproject.toml poetry.lock /app/
|
COPY pyproject.toml poetry.lock /app/
|
||||||
|
|
||||||
|
RUN pip install poetry
|
||||||
|
|
||||||
|
# Create virtualenv
|
||||||
|
RUN poetry config virtualenvs.create false
|
||||||
|
|
||||||
# Install the dependencies
|
# Install the dependencies
|
||||||
RUN poetry config virtualenvs.create false && \
|
RUN poetry install --no-root --no-dev
|
||||||
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
|
# Set the PYTHONPATH environment variable to include the /app directory
|
||||||
ENV PYTHONPATH=/app
|
ENV PYTHONPATH=/app
|
||||||
|
|
||||||
COPY cognee/ /app/cognee
|
COPY cognee/ /app/cognee
|
||||||
|
|
||||||
|
|
||||||
COPY entrypoint.sh /app/entrypoint.sh
|
COPY entrypoint.sh /app/entrypoint.sh
|
||||||
RUN chmod +x /app/entrypoint.sh
|
RUN chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
|
|
|
||||||
49
Dockerfile-old
Normal file
49
Dockerfile-old
Normal file
|
|
@ -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"]
|
||||||
|
|
@ -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"]
|
|
||||||
2
cognee-frontend/.dockerignore
Normal file
2
cognee-frontend/.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
.next
|
||||||
|
node_modules
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
# Use an official Node.js runtime as a parent image
|
# 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
|
# Set the working directory to /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package.json and package-lock.json to the working directory
|
# 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
|
# 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 the rest of the application code to the working directory
|
||||||
COPY . .
|
COPY src ./src
|
||||||
|
COPY public ./public
|
||||||
# Make port 3000 available to the world outside this container
|
COPY next.config.mjs .
|
||||||
EXPOSE 3000
|
COPY tsconfig.json .
|
||||||
|
|
||||||
# Build the app and run it
|
# Build the app and run it
|
||||||
CMD ["sh", "-c", "npm run dev"]
|
CMD npm run dev
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,21 @@ services:
|
||||||
- cognee-network
|
- cognee-network
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile-vanilla
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
- /app/cognee-frontend/
|
- /app/cognee-frontend/ # Ignore frontend code
|
||||||
environment:
|
environment:
|
||||||
- HOST=0.0.0.0
|
- HOST=0.0.0.0
|
||||||
- ENVIRONMENT=local
|
- ENVIRONMENT=local
|
||||||
- PYTHONPATH=.
|
- PYTHONPATH=.
|
||||||
ports:
|
ports:
|
||||||
- 8000:8000
|
- 8000:8000
|
||||||
- 5678:5678 # Debugging
|
# - 5678:5678 # Debugging
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpus: "4.0"
|
cpus: 4.0
|
||||||
memory: 8GB
|
memory: 8GB
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
|
|
@ -28,9 +28,11 @@ services:
|
||||||
context: ./cognee-frontend
|
context: ./cognee-frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- "./cognee-frontend:/app"
|
- ./cognee-frontend/src:/app/src
|
||||||
|
- ./cognee-frontend/public:/app/public
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- 3000:3000
|
||||||
|
# - 9229:9229 # Debugging
|
||||||
networks:
|
networks:
|
||||||
- cognee-network
|
- cognee-network
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,25 @@
|
||||||
version: "3.9"
|
|
||||||
|
|
||||||
services:
|
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:
|
cognee:
|
||||||
container_name: cognee
|
container_name: cognee
|
||||||
networks:
|
networks:
|
||||||
- cognee_backend
|
- cognee-network
|
||||||
build:
|
build:
|
||||||
context: ./
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- "./:/app"
|
- .:/app
|
||||||
- ./.data:/app/.data
|
- /app/cognee-frontend/ # Ignore frontend code
|
||||||
environment:
|
environment:
|
||||||
- HOST=0.0.0.0
|
- HOST=0.0.0.0
|
||||||
- ENVIRONMENT=local
|
- ENVIRONMENT=local
|
||||||
- PYTHONPATH=.
|
- PYTHONPATH=.
|
||||||
ports:
|
ports:
|
||||||
- 8000:8000
|
- 8000:8000
|
||||||
- 443:443
|
# - 5678:5678 # Debugging
|
||||||
- 80:80
|
|
||||||
- 50051:50051
|
|
||||||
- 5678:5678 # Debugging
|
|
||||||
depends_on:
|
|
||||||
- postgres
|
|
||||||
- neo4j
|
|
||||||
- frontend
|
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpus: "4.0"
|
cpus: 4.0
|
||||||
memory: 8GB
|
memory: 8GB
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
|
|
@ -48,36 +28,40 @@ services:
|
||||||
context: ./cognee-frontend
|
context: ./cognee-frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- "./cognee-frontend:/app"
|
- ./cognee-frontend/src:/app/src
|
||||||
|
- ./cognee-frontend/public:/app/public
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- 3000:3000
|
||||||
|
# - 9229:9229 # Debugging
|
||||||
networks:
|
networks:
|
||||||
- cognee_backend
|
- cognee-network
|
||||||
|
|
||||||
postgres:
|
neo4j:
|
||||||
image: postgres
|
image: neo4j:latest
|
||||||
container_name: postgres
|
container_name: neo4j
|
||||||
environment:
|
profiles:
|
||||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
- neo4j
|
||||||
- POSTGRES_USER=bla
|
ports:
|
||||||
- POSTGRES_PASSWORD=bla
|
- 7474:7474
|
||||||
- POSTGRES_DB=bubu
|
- 7687:7687
|
||||||
|
environment:
|
||||||
networks:
|
- NEO4J_AUTH=neo4j/pleaseletmein
|
||||||
- cognee_backend
|
- NEO4J_PLUGINS=["apoc"]
|
||||||
ports:
|
networks:
|
||||||
- "5432:5432"
|
- cognee-network
|
||||||
|
|
||||||
falkordb:
|
falkordb:
|
||||||
image: falkordb/falkordb:edge
|
image: falkordb/falkordb:edge
|
||||||
container_name: falkordb
|
container_name: falkordb
|
||||||
|
profiles:
|
||||||
|
- falkordb
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- 6379:6379
|
||||||
- "3001:3000"
|
- 3001:3000
|
||||||
networks:
|
networks:
|
||||||
- cognee_backend
|
- cognee-network
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
cognee_backend:
|
cognee-network:
|
||||||
name: cognee_backend
|
name: cognee-network
|
||||||
|
|
||||||
|
|
|
||||||
35
entrypoint-old.sh
Executable file
35
entrypoint-old.sh
Executable file
|
|
@ -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
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -1,35 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# export ENVIRONMENT
|
|
||||||
|
|
||||||
echo "Debug mode: $DEBUG"
|
echo "Debug mode: $DEBUG"
|
||||||
echo "Environment: $ENVIRONMENT"
|
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"
|
echo "Starting Gunicorn"
|
||||||
|
|
||||||
if [ "$DEBUG" = true ]; then
|
if [ "$ENVIRONMENT" = "local" ]; then
|
||||||
echo "Waiting for the debugger to attach..."
|
if [ "$DEBUG" = true ]; then
|
||||||
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
|
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
|
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
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue