From c06dcea501ccb0c378ca5fffc1518b1e69bdc504 Mon Sep 17 00:00:00 2001 From: Ernesto Serrano Date: Sat, 18 Mar 2023 13:31:55 +0000 Subject: [PATCH] Build and publish Docker image using GitHub Actions --- .github/workflows/docker.yml | 42 ++++++++++++++++++++++++++++++++++++ README.md | 14 ++++++------ 2 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..f573aa88 --- /dev/null +++ b/.github/workflows/docker.yml @@ -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 }} diff --git a/README.md b/README.md index 367ce821..092ddbc2 100644 --- a/README.md +++ b/README.md @@ -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 . +``` \ No newline at end of file