From d53bb3860b7cfef9f5de00b00b3e64f425d72636 Mon Sep 17 00:00:00 2001 From: Vladimir Aleksiev Date: Thu, 5 Dec 2024 16:11:19 +0200 Subject: [PATCH 1/4] fix ingest in Docker --- Dockerfile | 31 +++++++++---------------------- config.py | 4 ++-- poetry.lock | 8 ++++---- pyproject.toml | 2 +- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 17a67e9..78b4584 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,11 +10,15 @@ ARG HUGO_VERSION=0.121.2 ARG TARGETARCH # install git, go and hugo -RUN apt update && apt upgrade -y && apt install -y git wget +RUN apt-get upgrade -y +RUN apt-get update -y +RUN apt-get install -y git wget RUN wget https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz && tar -C /usr/local -xzf go${GO_VERSION}.linux-${TARGETARCH}.tar.gz + RUN export PATH=$PATH:/usr/local/go/bin:/usr/local && go version -RUN wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && tar -C /usr/local -xzf hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && ls -al /usr/local -RUN /usr/local/hugo version + +RUN wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && tar -C /bin -xzf hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && ls -al /usr/local +RUN hugo version # Install Poetry RUN pip install poetry @@ -22,25 +26,8 @@ RUN pip install poetry # Copy the current directory contents into the container at /app COPY . /app -# Use Poetry to install dependencies +# # Use Poetry to install dependencies RUN poetry config virtualenvs.create true && poetry install --no-interaction --no-ansi -# Start a new, final stage -FROM python:${PYTHON_VERSION}-slim-bullseye - -WORKDIR /app - -# Install git and Poetry in the final stage -RUN apt update && apt install -y git && pip install poetry - -# Copy the compiled app, Hugo executable, Go, and the virtual environment from the previous stage -COPY --from=builder /app /app -COPY --from=builder /usr/local/hugo /usr/local/hugo -COPY --from=builder /usr/local/go /usr/local/go -COPY --from=builder /root/.cache/pypoetry/virtualenvs /root/.cache/pypoetry/virtualenvs - -# Add Hugo and Go to the PATH -ENV PATH="/usr/local/hugo:/usr/local/go/bin:${PATH}" - -# Run virtual_contributor_engine_guidance.py when the container launches +# Run main.py when the container launches CMD ["poetry", "run", "python", "main.py"] diff --git a/config.py b/config.py index 38259d2..f3cb7df 100644 --- a/config.py +++ b/config.py @@ -46,8 +46,8 @@ def __init__(self): self.site_url = os.getenv("AI_SOURCE_WEBSITE", "") self.welcome_site_url = os.getenv("AI_SOURCE_WEBSITE2", "") - self.site_repo = os.getenv("AI_WEBSITE_REPO", "") - self.welcome_site_repo = os.getenv("AI_WEBSITE_REPO2", "") + self.site_repo = f"https://{os.getenv('AI_GITHUB_PAT', '')}@{os.getenv('AI_WEBSITE_REPO', '')}" + self.welcome_site_repo = f"https://{os.getenv('AI_GITHUB_PAT', '')}@{os.getenv('AI_WEBSITE_REPO2', '')}" self.github_user = os.getenv("AI_GITHUB_USER", "") self.github_pat = os.getenv("AI_GITHUB_PAT", "") diff --git a/poetry.lock b/poetry.lock index 2261b05..df51aca 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2034,13 +2034,13 @@ requests = ">=2.0.1,<3.0.0" [[package]] name = "six" -version = "1.16.0" +version = "1.17.0" description = "Python 2 and 3 compatibility utilities" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, + {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"}, + {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 8b8dc31..bca1897 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "virtual-contributor-engine-guidance" -version = "0.8.1" +version = "0.8.2" description = "Alkemio Generative AI Guidance Engine" authors = ["Alkemio BV "] license = "EUPL-1.2" From bb9a38f36840e10ab9828d168a74442b5eca9264 Mon Sep 17 00:00:00 2001 From: Vladimir Aleksiev Date: Thu, 5 Dec 2024 17:39:13 +0200 Subject: [PATCH 2/4] address coderabbit comments; fix logs --- Dockerfile | 14 ++++++++++++-- ingest.py | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 78b4584..1432043 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,15 +9,25 @@ ARG GO_VERSION=1.21.6 ARG HUGO_VERSION=0.121.2 ARG TARGETARCH +RUN apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y git wget \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + # install git, go and hugo RUN apt-get upgrade -y RUN apt-get update -y RUN apt-get install -y git wget RUN wget https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz && tar -C /usr/local -xzf go${GO_VERSION}.linux-${TARGETARCH}.tar.gz -RUN export PATH=$PATH:/usr/local/go/bin:/usr/local && go version +ENV PATH="/usr/local/go/bin:/usr/local:${PATH}" +RUN go version + +RUN wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz \ + && tar -C /bin -xzf hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz \ + && rm hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz -RUN wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && tar -C /bin -xzf hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && ls -al /usr/local RUN hugo version # Install Poetry diff --git a/ingest.py b/ingest.py index be2fe15..63f266b 100644 --- a/ingest.py +++ b/ingest.py @@ -45,10 +45,10 @@ def embed_text(documents: list[Document]): async def ensure_cloned(repo_name: str, path: str): if os.path.exists(path): - logger.info(f"Repository {repo_name} already cloned.") + logger.info(f"Repository {path} already cloned.") repo = Repo.init(path) else: - logger.info(f"Closning repository: {repo_name}") + logger.info(f"Closning repository: {path}") repo = Repo.clone_from(repo_name, path, branch="main") repo.heads.main.checkout() From ddd9b6c77e770dbfbe85dc771494daeba93d4915 Mon Sep 17 00:00:00 2001 From: Vladimir Aleksiev Date: Thu, 5 Dec 2024 17:42:10 +0200 Subject: [PATCH 3/4] fix typo --- ingest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ingest.py b/ingest.py index 63f266b..ed500a4 100644 --- a/ingest.py +++ b/ingest.py @@ -48,7 +48,7 @@ async def ensure_cloned(repo_name: str, path: str): logger.info(f"Repository {path} already cloned.") repo = Repo.init(path) else: - logger.info(f"Closning repository: {path}") + logger.info(f"Cloning repository: {path}") repo = Repo.clone_from(repo_name, path, branch="main") repo.heads.main.checkout() From 171a0a71e1c640f37affc5e84cdc765dd8a308fe Mon Sep 17 00:00:00 2001 From: Vladimir Aleksiev Date: Fri, 6 Dec 2024 09:40:29 +0200 Subject: [PATCH 4/4] remo unneded installations from Dockerfile --- Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1432043..3f4301a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,16 +9,13 @@ ARG GO_VERSION=1.21.6 ARG HUGO_VERSION=0.121.2 ARG TARGETARCH +# install wget and git RUN apt-get update -y \ && apt-get upgrade -y \ && apt-get install -y git wget \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -# install git, go and hugo -RUN apt-get upgrade -y -RUN apt-get update -y -RUN apt-get install -y git wget RUN wget https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz && tar -C /usr/local -xzf go${GO_VERSION}.linux-${TARGETARCH}.tar.gz ENV PATH="/usr/local/go/bin:/usr/local:${PATH}"