Build and publish Docker image using GitHub Actions

This commit is contained in:
Ernesto Serrano
2023-03-18 13:31:55 +00:00
committed by GitHub
parent 1312526af4
commit c06dcea501
2 changed files with 49 additions and 7 deletions
+42
View File
@@ -0,0 +1,42 @@
name: Docker Image CI
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: type=ref,event=tag
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+7 -7
View File
@@ -223,24 +223,24 @@ This is just some examples of what we can do using ChatGPT model, I'm sure you w
```
## Docker
Use the provided `Dockerfile` to build a container:
```shell
docker build -t sgpt .
```
Run the container using the `OPENAI_API_KEY` environment variable, and a docker volume to store cache:
```shell
docker run --rm \
--env OPENAI_API_KEY="your OPENAI API key" \
--volume gpt-cache:/tmp/shell_gpt \
sgpt --chat rainbow "what are the colors of a rainbow"
ghcr.io/TheR1D/shell_gpt --chat rainbow "what are the colors of a rainbow"
```
Example of a conversation, using an alias and the `OPENAI_API_KEY` environment variable:
```shell
alias sgpt="docker run --rm --env OPENAI_API_KEY --volume gpt-cache:/tmp/shell_gpt sgpt"
alias sgpt="docker run --rm --env OPENAI_API_KEY --volume gpt-cache:/tmp/shell_gpt ghcr.io/TheR1D/shell_gpt"
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"
```
You also can use the provided `Dockerfile` to build your own image:
```shell
docker build -t sgpt .
```