Skip to content

Commit

Permalink
Merge pull request #66 from alkem-io/fix-ingest-in-docker
Browse files Browse the repository at this point in the history
Fix ingest in Docker and bump version to 0.8.2
  • Loading branch information
valentinyanakiev authored Dec 6, 2024
2 parents a419ecd + 171a0a7 commit b89cd5b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 deletions.
42 changes: 18 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,32 @@ ARG GO_VERSION=1.21.6
ARG HUGO_VERSION=0.121.2
ARG TARGETARCH

# install git, go and hugo
RUN apt update && apt upgrade -y && apt install -y git wget
# 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/*

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

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 hugo version

# Install Poetry
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"]
4 changes: 2 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
Expand Down
4 changes: 2 additions & 2 deletions ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"Cloning repository: {path}")
repo = Repo.clone_from(repo_name, path, branch="main")

repo.heads.main.checkout()
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "EUPL-1.2"
Expand Down

0 comments on commit b89cd5b

Please sign in to comment.