From 8523c3025279beaf0b1f11105155a9c4269e3aa0 Mon Sep 17 00:00:00 2001 From: Nick1200000 Date: Sat, 10 May 2025 23:54:17 +0530 Subject: [PATCH 1/5] Added the Dockerfile for the GraphGen --- Dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..dec530a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +# Use a slim version of Python 3.10 as the base image +FROM python:3.10-slim + +# Environment variables to prevent Python from writing .pyc files +# and to ensure output is logged directly +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +# Set the working directory inside the container +WORKDIR /app + +# Install system dependencies required for building Python packages +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + git \ + build-essential && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy requirements file and install Python dependencies +COPY requirements.txt . +RUN pip install --upgrade pip && \ + pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code into the container +COPY . . + +# Create necessary directories +RUN mkdir -p cache/data/graphgen cache/logs + +# Environment variables for application config +ENV SYNTHESIZER_MODEL="" +ENV SYNTHESIZER_BASE_URL="" +ENV SYNTHESIZER_API_KEY="" +ENV TRAINEE_MODEL="" +ENV TRAINEE_BASE_URL="" +ENV TRAINEE_API_KEY="" + +# Expose the port the app will run on +EXPOSE 7860 + +# Command to run the application +CMD ["python", "webui/app.py"] From 288b5d34973e073b9d7e5bee4157fdf6b3262c7c Mon Sep 17 00:00:00 2001 From: Nikhil Kumar <92905941+Nick1200000@users.noreply.github.com> Date: Mon, 12 May 2025 10:49:18 +0530 Subject: [PATCH 2/5] Update Dockerfile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index dec530a0..1c1d353c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,5 +39,7 @@ ENV TRAINEE_API_KEY="" # Expose the port the app will run on EXPOSE 7860 +# Switch to the non-root user +USER appuser # Command to run the application CMD ["python", "webui/app.py"] From 8b53a0bab18ca8ab54c67fd00e8ca913554d516c Mon Sep 17 00:00:00 2001 From: Nikhil Kumar <92905941+Nick1200000@users.noreply.github.com> Date: Mon, 12 May 2025 10:50:02 +0530 Subject: [PATCH 3/5] Update Dockerfile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1c1d353c..742c3439 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,12 +29,12 @@ COPY . . RUN mkdir -p cache/data/graphgen cache/logs # Environment variables for application config -ENV SYNTHESIZER_MODEL="" -ENV SYNTHESIZER_BASE_URL="" -ENV SYNTHESIZER_API_KEY="" -ENV TRAINEE_MODEL="" -ENV TRAINEE_BASE_URL="" -ENV TRAINEE_API_KEY="" +ENV SYNTHESIZER_MODEL="" # Path to the synthesizer model file. Must be set at runtime. +ENV SYNTHESIZER_BASE_URL="" # Base URL for the synthesizer service. Must be set at runtime. +ENV SYNTHESIZER_API_KEY="" # API key for authenticating with the synthesizer service. Must be set at runtime. +ENV TRAINEE_MODEL="" # Path to the trainee model file. Must be set at runtime. +ENV TRAINEE_BASE_URL="" # Base URL for the trainee service. Must be set at runtime. +ENV TRAINEE_API_KEY="" # API key for authenticating with the trainee service. Must be set at runtime. # Expose the port the app will run on EXPOSE 7860 From 7b20114da596b9b52c7fe13ec8d1c621703a74af Mon Sep 17 00:00:00 2001 From: Nikhil Kumar <92905941+Nick1200000@users.noreply.github.com> Date: Mon, 12 May 2025 11:13:47 +0530 Subject: [PATCH 4/5] Update Dockerfile Removed the comment made by Github Copilot --- Dockerfile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 742c3439..0827b680 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # Copy requirements file and install Python dependencies -COPY requirements.txt . +COPY requirements.txt . RUN pip install --upgrade pip && \ pip install --no-cache-dir -r requirements.txt @@ -29,17 +29,18 @@ COPY . . RUN mkdir -p cache/data/graphgen cache/logs # Environment variables for application config -ENV SYNTHESIZER_MODEL="" # Path to the synthesizer model file. Must be set at runtime. -ENV SYNTHESIZER_BASE_URL="" # Base URL for the synthesizer service. Must be set at runtime. -ENV SYNTHESIZER_API_KEY="" # API key for authenticating with the synthesizer service. Must be set at runtime. -ENV TRAINEE_MODEL="" # Path to the trainee model file. Must be set at runtime. -ENV TRAINEE_BASE_URL="" # Base URL for the trainee service. Must be set at runtime. -ENV TRAINEE_API_KEY="" # API key for authenticating with the trainee service. Must be set at runtime. +ENV SYNTHESIZER_MODEL="" +ENV SYNTHESIZER_BASE_URL="" +ENV SYNTHESIZER_API_KEY="" +ENV TRAINEE_MODEL="" +ENV TRAINEE_BASE_URL="" +ENV TRAINEE_API_KEY="" # Expose the port the app will run on EXPOSE 7860 # Switch to the non-root user USER appuser + # Command to run the application CMD ["python", "webui/app.py"] From ceab75964a162847d5f163876536268282094049 Mon Sep 17 00:00:00 2001 From: Nikhil Kumar <92905941+Nick1200000@users.noreply.github.com> Date: Mon, 12 May 2025 11:29:57 +0530 Subject: [PATCH 5/5] Update Dockerfile Resolve the issue of appuser --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0827b680..0f3ab4d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Use a slim version of Python 3.10 as the base image FROM python:3.10-slim -# Environment variables to prevent Python from writing .pyc files +# Set environment variables to prevent Python from writing .pyc files # and to ensure output is logged directly ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 @@ -13,10 +13,13 @@ WORKDIR /app RUN apt-get update && \ apt-get install -y --no-install-recommends \ git \ - build-essential && \ - apt-get clean && \ + build-essential \ + && apt-get clean && \ rm -rf /var/lib/apt/lists/* +# Create a non-root user and switch to that user +RUN useradd -m appuser + # Copy requirements file and install Python dependencies COPY requirements.txt . RUN pip install --upgrade pip && \