mirror of
https://github.com/TheR1D/shell_gpt.git
synced 2026-07-03 14:10:18 +02:00
Docker OPENAI_API_KEY env variable
* feat: use new OPENAI_API_KEY variable in the docker part
This commit is contained in:
+2
-6
@@ -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"]
|
||||
|
||||
@@ -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"
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user