Docker OPENAI_API_KEY env variable

* feat: use new OPENAI_API_KEY variable in the docker part
This commit is contained in:
Éric
2023-03-14 01:47:17 +01:00
committed by GitHub
parent 02e5b619c9
commit e985358499
2 changed files with 7 additions and 11 deletions
+2 -6
View File
@@ -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"]
+5 -5
View File
@@ -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"
```