From 1f836abdf5d0ec6e9f18951729ca36cd9bcfca9d Mon Sep 17 00:00:00 2001 From: arikw <7900646+arikw@users.noreply.github.com> Date: Mon, 8 May 2023 04:33:18 +0300 Subject: [PATCH] add docker support --- .dockerignore | 6 ++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ README.md | 20 ++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2ca75ad --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +# exclude +.* +Dockerfile + +# include +!.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..58d889f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Use an official Python base image from the Docker Hub +FROM python:3-alpine AS loopgpt-base + +# Install browsers +RUN apk update && apk add --no-cache \ + firefox \ + ca-certificates + +# Install utilities +RUN apk add --no-cache curl jq wget git gcc g++ libc-dev bash + +# Set environment variables +ENV PIP_NO_CACHE_DIR=yes \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 + +RUN adduser -D -g gpt -s /bin/bash gpt + +WORKDIR /app +COPY requirements.txt setup.py ./ +RUN chown -R gpt:gpt . && chmod -R 755 . + +USER gpt:gpt + +RUN pip install --user -e . + +COPY --chown=gpt:gpt . ./ + +ENV DISPLAY=:99 \ + PATH=/home/gpt/.local/bin:$PATH diff --git a/README.md b/README.md index 2d8fc7f..6f30bf4 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,13 @@ cd loopgpt pip install -e . ``` +### Install from source (dev) using Docker +```bash +git clone https://www.github.com/farizrahman4u/loopgpt.git@main +cd loopgpt +docker build -t loopgpt:local-dev . +``` + ## 🏎️ Getting Started ### Setup your OpenAI API Key 🔑 @@ -143,6 +150,19 @@ loopgpt run Run `loopgpt --help` to see all the available options. +### 🐋 Docker Mode + +You can run L♾️pGPT in the previously mentioned modes, using Docker: + +```bash +# CLI mode +docker run -i --rm loopgpt:local-dev loopgpt run + +# Script mode example +docker run -i --rm -v "$(pwd)/scripts:/scripts" loopgpt:local-dev python /scripts/myscript.py + +``` + ## ⚒️ Adding custom tools ⚒️ L♾️pGPT agents come with a set of builtin tools which allows them to perform various basic tasks such as searching the web, filesystem operations, etc. You can view these tools with `print(agent.tools)`.