Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
## What

...
-

## Why

...
-

## How

...
-

## Database Migrations

-

## Env Config

-

## Relevant Docs

Expand All @@ -18,18 +26,16 @@

-

## Dependencies Versions / Env Variables
## Dependencies Versions

-

## Notes on Testing

...
-

## Screenshots

...

## Checklist

I have read and understood the [Contribution Guidelines]().
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Use LLMs to eliminate manual processes involving unstructured data.

Just run the `run-platform.sh` launch script to get started in few minutes.

The launch script does env setup with default values, pulls public Docker images or builds them locally and finally runs them in containers.
The launch script does env setup with default values, pulls public docker images or builds them locally and finally runs them in containers.

```bash
# Pull and run entire Unstract platform with default env config.
Expand All @@ -24,19 +24,22 @@ The launch script does env setup with default values, pulls public Docker images
# Pull and run docker containers with a specific version tag.
./run-platform.sh -v v0.1.0

# Build docker images and run as containers with a specific version tag.
./run-platform.sh -B -v v0.1.0
# Build docker images locally and run with a specific version tag.
./run-platform.sh -b -v v0.1.0

# Display the help information.
./run-platform.sh -h

# Only do setup of environment files.
./run-platform.sh -e

# Only do docker images pull/build with a specific version tag.
./run-platform.sh -b v0.1.0
# Only do docker images pull with a specific version tag.
./run-platform.sh -p -v v0.1.0

# Pull and run Docker containers in detached mode.
# Only do docker images pull by building locally with a specific version tag.
./run-platform.sh -p -b -v v0.1.0

# Pull and run docker containers in detached mode.
./run-platform.sh -d -v v0.1.0
```

Expand Down
4 changes: 4 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ services:
- redis
- reverse-proxy
- minio
- platform-service
- prompt-service
- x2text-service
volumes:
- ./workflow_data:/data
environment:
Expand Down Expand Up @@ -140,6 +143,7 @@ services:
- ../worker/.env
volumes:
- ./workflow_data:/data
# Docker socket bind mount to spawn tool containers
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- redis
Expand Down
17 changes: 9 additions & 8 deletions docker/dockerfiles/document.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update; \
unoconv; \
apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \
\
pip install --no-cache-dir -U pip pdm~=${PDM_VERSION};
pip install --no-cache-dir -U pip pdm~=${PDM_VERSION}; \
\
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
adduser -u 5678 --disabled-password --gecos "" unstract;

EXPOSE 3002
USER unstract

WORKDIR /app

COPY ${BUILD_CONTEXT_PATH}/ .
COPY --chown=unstract ${BUILD_CONTEXT_PATH}/ .

RUN set -e; \
\
Expand All @@ -45,13 +49,10 @@ RUN set -e; \
# REF: https://docs.gunicorn.org/en/stable/deploy.html#using-virtualenv
pip install --no-cache-dir gunicorn; \
\
# Storage for document uploads and processing
mkdir /app/uploads /app/processed;

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" unstract;

USER unstract
EXPOSE 3002

# Wrapper to run both python server and libreoffice.
CMD [ "/app/wrapper.sh" ]
18 changes: 9 additions & 9 deletions docker/dockerfiles/platform.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ ENV BUILD_CONTEXT_PATH platform-service
ENV BUILD_PACKAGES_PATH unstract
ENV PDM_VERSION 2.12.3

RUN pip install --no-cache-dir -U pip pdm~=${PDM_VERSION};
RUN pip install --no-cache-dir -U pip pdm~=${PDM_VERSION}; \
\
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
adduser -u 5678 --disabled-password --gecos "" unstract;

USER unstract

WORKDIR /app

COPY ${BUILD_CONTEXT_PATH} .
COPY --chown=unstract ${BUILD_CONTEXT_PATH} .
# Copy local dependency packages
COPY ${BUILD_PACKAGES_PATH} /unstract
COPY --chown=unstract ${BUILD_PACKAGES_PATH} /unstract

RUN set -e; \
\
Expand All @@ -35,11 +41,5 @@ RUN set -e; \

EXPOSE 3001

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" unstract;

USER unstract

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD [".venv/bin/gunicorn", "--bind", "0.0.0.0:3001", "--timeout", "300", "unstract.platform_service.main:app"]
18 changes: 12 additions & 6 deletions docker/dockerfiles/prompt.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ RUN apt-get update; \
git; \
apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \
\
pip install --no-cache-dir -U pip pdm~=${PDM_VERSION};
pip install --no-cache-dir -U pip pdm~=${PDM_VERSION}; \
\
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
adduser -u 5678 --disabled-password --gecos "" unstract;

USER unstract

WORKDIR /app

COPY ${BUILD_CONTEXT_PATH} .
COPY --chown=unstract ${BUILD_CONTEXT_PATH} .

RUN set -e; \
\
Expand Down Expand Up @@ -61,10 +67,10 @@ RUN set -e; \
#
\
# REF: https://docs.gunicorn.org/en/stable/deploy.html#using-virtualenv
pip install --no-cache-dir gunicorn;

# Storage for prompt studio uploads
RUN mkdir prompt-studio-data
pip install --no-cache-dir gunicorn; \
\
# Storage for prompt studio uploads
mkdir prompt-studio-data;

EXPOSE 3003

Expand Down
5 changes: 0 additions & 5 deletions docker/dockerfiles/worker.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ RUN set -e; \
# REF: https://docs.gunicorn.org/en/stable/deploy.html#using-virtualenv
pip install --no-cache-dir gunicorn gevent;


EXPOSE 5002

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" unstract;

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
# The suggested maximum concurrent requests when using workers and threads is (2*CPU)+1
CMD [ "./entrypoint.sh" ]
16 changes: 8 additions & 8 deletions docker/dockerfiles/x2text.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ ENV PYTHONUNBUFFERED 1
ENV BUILD_CONTEXT_PATH x2text-service
ENV PDM_VERSION 2.12.3

RUN pip install --no-cache-dir -U pip pdm~=${PDM_VERSION}
RUN pip install --no-cache-dir -U pip pdm~=${PDM_VERSION}; \
\
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
adduser -u 5678 --disabled-password --gecos "" unstract;

USER unstract

WORKDIR /app

COPY ${BUILD_CONTEXT_PATH} .
COPY --chown=unstract ${BUILD_CONTEXT_PATH} .

RUN set -e; \
\
Expand All @@ -31,12 +37,6 @@ RUN set -e; \

EXPOSE 3004

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" unstract;

USER unstract

# During debugging, this entry point will be overridden.
# For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD [".venv/bin/gunicorn", "--bind", "0.0.0.0:3004", "--timeout", "300", "run:app"]
20 changes: 10 additions & 10 deletions run-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ display_help() {
echo -e "Options:"
echo -e " -h, --help Displays the help information"
echo -e " -e, --only-env Only do env files setup"
echo -e " -b, --only-build Only do docker images build"
echo -e " -B, --build-local Build docker images locally"
echo -e " -p, --only-pull Only do docker images pull"
echo -e " -b, --build-local Build docker images locally"
echo -e " -d, --detach Run docker containers in detached mode"
echo -e " -x, --trace Enables trace mode"
echo -e " -V, --verbose Print verbose logs"
echo -e " -v, --version Docker images version tag (default \"dev\")"
echo -e " -v, --version Docker images version tag (default \"latest\")"
echo -e ""
}

Expand All @@ -62,10 +62,10 @@ parse_args() {
-e | --only-env)
opt_only_env=true
;;
-b | --only-build)
opt_only_build=true
-p | --only-pull)
opt_only_pull=true
;;
-B | --build-local)
-b | --build-local)
opt_build_local=true
;;
-d | --detach)
Expand All @@ -92,7 +92,7 @@ parse_args() {
done

debug "OPTION only_env: $opt_only_env"
debug "OPTION only_build: $opt_only_build"
debug "OPTION only_pull: $opt_only_pull"
debug "OPTION build_local: $opt_build_local"
debug "OPTION detach: $opt_detach"
debug "OPTION verbose: $opt_verbose"
Expand Down Expand Up @@ -163,7 +163,7 @@ build_services() {

popd 1>/dev/null

if [ "$opt_only_build" = true ]; then
if [ "$opt_only_pull" = true ]; then
echo "Done." && exit 0
fi
}
Expand Down Expand Up @@ -192,11 +192,11 @@ if ! command -v docker compose &> /dev/null; then
fi

opt_only_env=false
opt_only_build=false
opt_only_pull=false
opt_build_local=false
opt_detach=""
opt_verbose=false
opt_version="dev"
opt_version="latest"

script_dir=$(dirname "$(readlink -f "$BASH_SOURCE")")
# Extract service names from docker compose file.
Expand Down