Skip to content

Commit

Permalink
enhance: support enterprise docker builds
Browse files Browse the repository at this point in the history
Add the `ENTERPRISE` Docker build argument to the Dockerfile and build
scripts. When set to `"true"` the enterprise tool registry will be
packaged in the image and Obot will be configured to use it when the
container starts.

Signed-off-by: Nick Hale <[email protected]>
  • Loading branch information
njhale committed Jan 13, 2025
1 parent 6612259 commit 5dd8dab
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG ENTERPRISE=false

FROM cgr.dev/chainguard/wolfi-base AS base

RUN apk add --no-cache go make git npm pnpm
Expand All @@ -12,14 +14,15 @@ RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
make all

FROM base AS tools
ARG ENTERPRISE
RUN apk add --no-cache curl python-3.13 py3.13-pip
WORKDIR /app
COPY . .
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/.cache/uv \
--mount=type=cache,target=/root/go/pkg/mod \
UV_LINK_MODE=copy BIN_DIR=/bin make package-tools
UV_LINK_MODE=copy BIN_DIR=/bin ENTERPRISE=$ENTERPRISE make package-tools

FROM cgr.dev/chainguard/postgres:latest-dev AS build-pgvector
RUN apk add build-base git postgresql-dev
Expand All @@ -32,6 +35,7 @@ RUN git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git && \
rm -rf pgvector

FROM cgr.dev/chainguard/postgres:latest-dev AS final
ARG ENTERPRISE
ENV POSTGRES_USER=obot
ENV POSTGRES_PASSWORD=obot
ENV POSTGRES_DB=obot
Expand Down Expand Up @@ -60,7 +64,7 @@ ENV XDG_CACHE_HOME=/data/cache
ENV GPTSCRIPT_SYSTEM_TOOLS_DIR=/obot-tools/
ENV OBOT_SERVER_WORKSPACE_TOOL=/obot-tools/workspace-provider
ENV OBOT_SERVER_DATASETS_TOOL=/obot-tools/datasets
ENV OBOT_SERVER_TOOL_REGISTRY=/obot-tools
ENV ENTERPRISE=$ENTERPRISE
ENV OBOT_SERVER_ENCRYPTION_CONFIG_FILE=/encryption.yaml
ENV BAAAH_THREADINESS=20
ENV TERM=vt100
Expand Down
12 changes: 12 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ if [[ -v ENABLE_SSHD ]]; then
fi

mkdir -p /data/cache


# This is YAML
export OBOT_SERVER_VERSIONS="$(cat <<VERSIONS
"github.com/obot-platform/tools": "$(cd /obot-tools && git rev-parse HEAD)"
Expand All @@ -32,6 +34,16 @@ export OBOT_SERVER_VERSIONS="$(cat <<VERSIONS
VERSIONS
)"

export OBOT_SERVER_TOOL_REGISTRIES="github.com/obot-platform/tools:/obot-tools"
if [ "${ENTERPRISE}" = "true" ]; then
OBOT_SERVER_TOOL_REGISTRIES+=",github.com/obot-platform/enterprise-tools:/obot-enterprise-tools"
export OBOT_SERVER_VERSIONS="$(cat <<VERSIONS
"github.com/obot-platform/enterprise-tools": "$(cd /obot-enterprise-tools && git rev-parse HEAD)"
${OBOT_SERVER_VERSIONS}
VERSIONS
)"
fi

if [ -z "$OBOT_SERVER_DSN" ]; then
echo "OBOT_SERVER_DSN is not set. Starting PostgreSQL process..."

Expand Down
20 changes: 20 additions & 0 deletions tools/package-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ if [ ! -e workspace-provider ]; then
git clone --depth=1 https://github.com/gptscript-ai/workspace-provider
fi

if [ "${ENTERPRISE}" = "true" ]; then
if [ ! -e obot-enterprise-tools ]; then
git clone --depth=1 https://github.com/obot-platform/enterprise-tools obot-enterprise-tools
fi

./obot-enterprise-tools/scripts/build.sh

for pj in $(find obot-enterprise-tools -name package.json | grep -v node_modules); do
if [ $(basename $(dirname $pj)) == common ]; then
continue
fi
(
cd $(dirname $pj)
echo Building $PWD
pnpm i
)
done

fi

cd workspace-provider
go build -ldflags="-s -w" -o bin/gptscript-go-tool .

Expand Down

0 comments on commit 5dd8dab

Please sign in to comment.