From e98535849973faa2ca6736c940131d308c1eb70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric?= <89578893+eric-glb@users.noreply.github.com> Date: Tue, 14 Mar 2023 01:47:17 +0100 Subject: [PATCH] Docker OPENAI_API_KEY env variable * feat: use new OPENAI_API_KEY variable in the docker part --- Dockerfile | 8 ++------ README.md | 10 +++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index a894026..31d1228 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,15 +9,11 @@ COPY . /app RUN pip install --no-cache --upgrade pip \ && pip install --no-cache /app \ && addgroup --system app && adduser --system --group app \ - && mkdir -p /home/app/.config/shell-gpt \ - /tmp/shell_gpt \ - && echo "api_key.txt should be here" > /home/app/.config/shell-gpt/readme.txt \ - && chown -R app:app /home/app \ - /tmp/shell_gpt + && mkdir -p /tmp/shell_gpt \ + && chown -R app:app /tmp/shell_gpt USER app -VOLUME /home/app/.config/shell-gpt VOLUME /tmp/shell_gpt ENTRYPOINT ["sgpt"] diff --git a/README.md b/README.md index 2fab4ad..c4ec132 100644 --- a/README.md +++ b/README.md @@ -205,19 +205,19 @@ Use the provided `Dockerfile` to build a container: docker build -t sgpt . ``` -You may use named volumes (sgpt will then ask your API key only once, and the cache will be reused for `--chat`) to run the container: +Run the container using the `OPENAI_API_KEY` environment variable, and a docker volume to store cache: ```shell docker run --rm \ - --volume gpt-config:/home/app/.config/shell-gpt \ + --env OPENAI_API_KEY="your OPENAI API key" \ --volume gpt-cache:/tmp/shell_gpt \ sgpt --chat rainbow "what are the colors of a rainbow" ``` -Example using an alias: +Example of a conversation, using an alias and the `OPENAI_API_KEY` environment variable: ```shell -alias sgpt="docker run --rm --volume gpt-config:/home/app/.config/shell-gpt --volume gpt-cache:/tmp/shell_gpt sgpt" +alias sgpt="docker run --rm --env OPENAI_API_KEY --volume gpt-cache:/tmp/shell_gpt sgpt" +export OPENAI_API_KEY="your OPENAI API key" sgpt --chat rainbow "what are the colors of a rainbow" sgpt --chat rainbow "inverse the list of your last answer" sgpt --chat rainbow "translate your last answer in french" ``` -