From ee67258beb8c3a0b4ee0286925763fd1ad0c450b Mon Sep 17 00:00:00 2001 From: LUIS NOVO Date: Fri, 8 Nov 2024 18:30:34 -0300 Subject: [PATCH] add full docker image with db --- .dockerignore | 3 +++ .gitignore | 1 + Dockerfile | 5 +++-- Dockerfile_full | 36 ++++++++++++++++++++++++++++++++++++ Makefile | 6 ++++-- docker-compose.full.yml | 13 +++++++++++++ supervisord.conf | 21 +++++++++++++++++++++ 7 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 Dockerfile_full create mode 100644 docker-compose.full.yml create mode 100644 supervisord.conf diff --git a/.dockerignore b/.dockerignore index 4bea5cb..f6df8f5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -13,3 +13,6 @@ docker-compose* docs/ surreal-data/ temp/ +*.env +.mypy_cache/ +.ruff_cache/ diff --git a/.gitignore b/.gitignore index 11d4a4b..5bf6efc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.env prompts/patterns/user/ notebooks/ data/ diff --git a/Dockerfile b/Dockerfile index 052cadc..f3b9e00 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,10 @@ RUN pip install poetry --no-cache-dir RUN poetry self add poetry-plugin-dotenv RUN poetry config virtualenvs.create false -COPY . /app - +COPY pyproject.toml poetry.lock /app/ RUN poetry install --only main + +COPY . /app EXPOSE 8502 RUN mkdir -p /app/data diff --git a/Dockerfile_full b/Dockerfile_full new file mode 100644 index 0000000..769a973 --- /dev/null +++ b/Dockerfile_full @@ -0,0 +1,36 @@ +# Use an official Python runtime as a base image +FROM python:3.11.7-slim-bullseye + +# Install system dependencies required for building certain Python packages +RUN apt-get update && apt-get install -y \ + gcc \ + curl wget libmagic-dev ffmpeg supervisor \ + && rm -rf /var/lib/apt/lists/* + +# Install SurrealDB +RUN curl --proto '=https' --tlsv1.2 -sSf https://install.surrealdb.com | sh + +# Set the working directory in the container to /app +WORKDIR /app + +COPY pyproject.toml poetry.lock /app/ +RUN pip install poetry --no-cache-dir +RUN poetry self add poetry-plugin-dotenv +RUN poetry config virtualenvs.create false + +RUN poetry install --only main + +COPY . /app + +# Create supervisor configuration directory +RUN mkdir -p /etc/supervisor/conf.d + +# Copy supervisor configuration file +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +EXPOSE 8502 + +RUN mkdir -p /app/data + +# Use supervisor as the main process +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/Makefile b/Makefile index f9f6152..5a689d9 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,8 @@ docker-update-latest: docker-buildx-prepare # Release with latest docker-release-all: docker-release docker-update-latest - dev: - docker compose -f docker-compose.dev.yml up --build \ No newline at end of file + docker compose -f docker-compose.dev.yml up --build + +full: + docker compose -f docker-compose.full.yml up --build \ No newline at end of file diff --git a/docker-compose.full.yml b/docker-compose.full.yml new file mode 100644 index 0000000..b6d2299 --- /dev/null +++ b/docker-compose.full.yml @@ -0,0 +1,13 @@ +version: '3' + +services: + open_notebook_full: + build: + context: . + dockerfile: Dockerfile_full + ports: + - "8080:8502" + volumes: + - ./.docker_data/data:/app/data + - ./docker2.env:/app/.env + - ./google-credentials.json:/app/google-credentials.json diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..ca59e8b --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,21 @@ +[supervisord] +nodaemon=true +logfile=/dev/stdout +logfile_maxbytes=0 +pidfile=/tmp/supervisord.pid + +[program:surrealdb] +command=surreal start --log trace --user root --pass root rocksdb:/mydata/mydatabase.db +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=true + +[program:streamlit] +command=poetry run streamlit run app_home.py +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=true