Skip to content

Commit

Permalink
docker image with endpoint entry (#22)
Browse files Browse the repository at this point in the history
* build backend with endpoint entry

* add curl to the entrypoint based image

* poetry version from pyproject.xml
  • Loading branch information
zzzming authored Jun 3, 2024
1 parent 9ed2d2a commit e45efdb
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .github/actions/ragstack-docker-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ runs:
shell: bash
run: |
backend_full_name=ghcr.io/datastax/ragstack-ai-langflow-backend
backend_ep_full_name=ghcr.io/datastax/ragstack-ai-langflow-backend-ep
frontend_full_name=ghcr.io/datastax/ragstack-ai-langflow-frontend
v="${{ inputs.version }}"
Expand All @@ -49,6 +50,10 @@ runs:
docker push $backend_full_name:$v
docker push $backend_full_name:latest
docker tag ragstack-ai-langflow-backend-ep:latest $backend_ep_full_name:$v
docker tag ragstack-ai-langflow-backend-ep:latest $backend_ep_full_name:latest
docker push $backend_ep_full_name:$v
docker push $backend_ep_full_name:latest
docker tag ragstack-ai-langflow-frontend:latest $frontend_full_name:$v
docker tag ragstack-ai-langflow-frontend:latest $frontend_full_name:latest
Expand Down
45 changes: 45 additions & 0 deletions ragstack/docker/backend-ep/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM python:3.11-slim-bookworm as builder
RUN pip install poetry==1.7.1

ENV POETRY_VIRTUALENVS_IN_PROJECT=1
ENV POETRY_VIRTUALENVS_CREATE=1
ENV POETRY_CACHE_DIR=/tmp/poetry_cache

ARG DEBIAN_FRONTEND=noninteractive
RUN echo 'Acquire::http::Timeout "30";\nAcquire::http::ConnectionAttemptDelayMsec "2000";\nAcquire::https::Timeout "30";\nAcquire::https::ConnectionAttemptDelayMsec "2000";\nAcquire::ftp::Timeout "30";\nAcquire::ftp::ConnectionAttemptDelayMsec "2000";\nAcquire::Retries "15";' > /etc/apt/apt.conf.d/99timeout_and_retries \
&& apt-get update && apt-get -y dist-upgrade && apt-get -y install gcc
RUN mkdir /app
COPY pyproject.toml poetry.lock* README* /app/

COPY src/backend /app/src/backend

RUN cd /app && poetry install --no-interaction --no-ansi -E deploy

FROM python:3.11-slim-bookworm as runtime

ARG VERSION
RUN echo "The version is: $VERSION"

LABEL org.opencontainers.image.title=ragstack-ai-langflow
LABEL org.opencontainers.image.version=$VERSION
LABEL org.opencontainers.image.authors=['DataStax']
LABEL org.opencontainers.image.licenses=BUSL-1.1
LABEL org.opencontainers.image.url=https://github.com/datastax/ragstack-ai-langflow
LABEL org.opencontainers.image.source=https://github.com/datastax/ragstack-ai-langflow

# Update package list and install curl
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1

RUN useradd ragstack -u 10000 -g 0 --no-create-home --home-dir /app/data
RUN mkdir /data
RUN chown -R 10000:0 /data

USER 10000

WORKDIR /app
COPY --from=builder --chown=10000 /app/ /app/

ENTRYPOINT ["langflow", "run", "--host", "0.0.0.0", "--backend-only"]
10 changes: 4 additions & 6 deletions ragstack/docker/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@ RUN cd /app && poetry install --no-interaction --no-ansi -E deploy

FROM python:3.11-slim-bookworm as runtime

ARG VERSION
RUN echo "The version is: $VERSION"

LABEL org.opencontainers.image.title=ragstack-ai-langflow
LABEL org.opencontainers.image.version=0.0.2
LABEL org.opencontainers.image.version=$VERSION
LABEL org.opencontainers.image.authors=['DataStax']
LABEL org.opencontainers.image.licenses=BUSL-1.1
LABEL org.opencontainers.image.url=https://github.com/datastax/ragstack-ai-langflow
LABEL org.opencontainers.image.source=https://github.com/datastax/ragstack-ai-langflow

# Update package list and install curl
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1

RUN useradd ragstack -u 10000 -g 0 --no-create-home --home-dir /app/data
RUN mkdir /data
RUN chown -R 10000:0 /data

USER 10000

Expand Down
33 changes: 31 additions & 2 deletions ragstack/docker/build-backend.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
#!/bin/bash
set -e
RAGSTACK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )"

cd $RAGSTACK_DIR
if command -v poetry &> /dev/null
then
version=$(poetry version | awk '{print $2}')
else
pyproject="$RAGSTACK_DIR/../pyproject.toml"
echo "pyproject file $pyproject"
if [[ -f "$pyproject" ]]; then
version=$(grep "^version" $pyproject | awk -F'=' '{gsub(/ /,"",$2); print $2}' | tr -d '"')
if [[ -n "$version" ]]; then
echo "Poetry is not installed. Version from pyproject.toml: $version"
else
echo "Version not found in $pyproject."
exit 1
fi
else
echo "pyproject.toml file $pyproject not found."
exit 1
fi
fi

echo "build docker image version $version ..."

cd $RAGSTACK_DIR/docker/backend
echo "Building backend image"
docker build -t ragstack-ai-langflow-backend:latest -f Dockerfile ../../..
echo "Done ragstack-ai-langflow-backend:latest "
docker build --build-arg VERSION=${version} -t ragstack-ai-langflow-backend:latest -f Dockerfile ../../..
echo "Done ragstack-ai-langflow-backend:latest "

cd $RAGSTACK_DIR/docker/backend-ep
docker build --build-arg VERSION=${version} -t ragstack-ai-langflow-backend-ep:latest -f Dockerfile ../../..
echo "Done ragstack-ai-langflow-backend-ep:latest "

0 comments on commit e45efdb

Please sign in to comment.