Skip to content

Commit ae81abe

Browse files
committed
ci(docker): build and publish image to GHCR; docs: add GHCR pull/run instructions
1 parent f670ccf commit ae81abe

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: docker-publish
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
tags: [ 'v*.*.*' ]
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Extract metadata (tags, labels)
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ toLower(env.IMAGE_NAME) }}
41+
tags: |
42+
type=ref,event=branch
43+
type=ref,event=tag
44+
type=sha
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
47+
- name: Build and push
48+
uses: docker/build-push-action@v6
49+
with:
50+
context: .
51+
push: true
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,16 @@ docker build -t supportbot:latest .
9393
# Persist DB to a local folder (PowerShell)
9494
mkdir data
9595
# Run container (maps http://localhost:8000)
96-
docker run --rm -p 8000:8000 -v ${PWD}\data:/data -e CHATBOT_DB_PATH=/data/database.sqlite3 supportbot:latest
96+
docker run --rm -p 8000:8000 -v ${PWD}\\data:/data -e CHATBOT_DB_PATH=/data/database.sqlite3 supportbot:latest
97+
```
98+
99+
Or pull a published image from GHCR (after the CI publishes at least once):
100+
101+
```bash
102+
# Pull latest image
103+
docker pull ghcr.io/swoet/ai-driven-chatbot-python-chatterbot-:latest
104+
# Run it
105+
docker run --rm -p 8000:8000 -v ${PWD}\\data:/data -e CHATBOT_DB_PATH=/data/database.sqlite3 ghcr.io/swoet/ai-driven-chatbot-python-chatterbot-:latest
97106
```
98107

99108
Stop with Ctrl+C and the DB remains in the local data folder.

0 commit comments

Comments
 (0)