chore: run alembic migrations in docker entrypoint

This commit is contained in:
Boris Arzentar 2024-10-16 23:32:32 +02:00
parent 3a636c0db0
commit 091fa35aab
3 changed files with 9 additions and 51 deletions

View file

@ -13,7 +13,7 @@ COPY pyproject.toml poetry.lock /app/
RUN pip install poetry
# Create virtualenv
# Don't create virtualenv since docker is already isolated
RUN poetry config virtualenvs.create false
# Install the dependencies
@ -22,7 +22,11 @@ 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 cognee/ cognee/
# Copy Alembic configuration
COPY alembic.ini ./
COPY alembic/ alembic/
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

View file

@ -1,49 +0,0 @@
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"]

View file

@ -3,6 +3,9 @@
echo "Debug mode: $DEBUG"
echo "Environment: $ENVIRONMENT"
# Run migrations
poetry run alembic upgrade head
echo "Starting Gunicorn"
if [ "$ENVIRONMENT" = "dev" ]; then