Skip to content

Commit 15db6da

Browse files
committed
feat: build
1 parent a7d723c commit 15db6da

File tree

3 files changed

+120
-1
lines changed

3 files changed

+120
-1
lines changed

.github/workflows/build.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Build and push tg-bot-docsgpt-extenstion Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Trigger on push to main branch
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
include:
13+
- platform: linux/amd64
14+
runner: ubuntu-latest
15+
suffix: amd64
16+
- platform: linux/arm64
17+
runner: ubuntu-24.04-arm
18+
suffix: arm64
19+
runs-on: ${{ matrix.runner }}
20+
permissions:
21+
contents: read
22+
packages: write
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up QEMU # Only needed for emulation, not for native arm64 builds
27+
uses: docker/setup-qemu-action@v3
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
with:
32+
driver: docker-container
33+
install: true
34+
35+
- name: Login to DockerHub
36+
uses: docker/login-action@v3
37+
with:
38+
username: ${{ secrets.DOCKER_USERNAME }}
39+
password: ${{ secrets.DOCKER_PASSWORD }}
40+
41+
- name: Login to ghcr.io
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ghcr.io
45+
username: ${{ github.repository_owner }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Build and push platform-specific images
49+
uses: docker/build-push-action@v6
50+
with:
51+
file: './Dockerfile'
52+
platforms: ${{ matrix.platform }}
53+
context: .
54+
push: true
55+
tags: |
56+
${{ secrets.DOCKER_USERNAME }}/tg-bot-docsgpt-extenstion:latest-${{ matrix.suffix }}
57+
ghcr.io/${{ github.repository_owner }}/tg-bot-docsgpt-extenstion:latest-${{ matrix.suffix }}
58+
provenance: false
59+
sbom: false
60+
cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/tg-bot-docsgpt-extenstion:latest
61+
cache-to: type=inline
62+
63+
manifest:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
permissions:
67+
packages: write
68+
steps:
69+
- name: Set up Docker Buildx
70+
uses: docker/setup-buildx-action@v3
71+
with:
72+
driver: docker-container
73+
install: true
74+
75+
- name: Login to DockerHub
76+
uses: docker/login-action@v3
77+
with:
78+
username: ${{ secrets.DOCKER_USERNAME }}
79+
password: ${{ secrets.DOCKER_PASSWORD }}
80+
81+
- name: Login to ghcr.io
82+
uses: docker/login-action@v3
83+
with:
84+
registry: ghcr.io
85+
username: ${{ github.repository_owner }}
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Create and push manifest for DockerHub
89+
run: |
90+
set -e
91+
docker manifest create ${{ secrets.DOCKER_USERNAME }}/tg-bot-docsgpt-extenstion:latest \
92+
--amend ${{ secrets.DOCKER_USERNAME }}/tg-bot-docsgpt-extenstion:latest-amd64 \
93+
--amend ${{ secrets.DOCKER_USERNAME }}/tg-bot-docsgpt-extenstion:latest-arm64
94+
docker manifest push ${{ secrets.DOCKER_USERNAME }}/tg-bot-docsgpt-extenstion:latest
95+
96+
- name: Create and push manifest for ghcr.io
97+
run: |
98+
set -e
99+
docker manifest create ghcr.io/${{ github.repository_owner }}/tg-bot-docsgpt-extenstion:latest \
100+
--amend ghcr.io/${{ github.repository_owner }}/tg-bot-docsgpt-extenstion:latest-amd64 \
101+
--amend ghcr.io/${{ github.repository_owner }}/tg-bot-docsgpt-extenstion:latest-arm64
102+
docker manifest push ghcr.io/${{ github.repository_owner }}/tg-bot-docsgpt-extenstion:latest

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.12-slim
3+
4+
# Set the working directory in the container
5+
WORKDIR /app
6+
7+
# Copy the requirements file into the container at /app
8+
COPY requirements.txt .
9+
10+
# Install any needed packages specified in requirements.txt
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
# Copy the current directory contents into the container at /app
14+
COPY bot.py .
15+
16+
# Run bot.py when the container launches
17+
CMD ["python", "bot.py"]

bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def generate_answer(question: str, messages: list, conversation_id: str |
4848
payload = {
4949
"question": question,
5050
"api_key": API_KEY,
51-
"history": messages,
51+
"history": "[]",
5252
"conversation_id": conversation_id
5353
}
5454
headers = {

0 commit comments

Comments
 (0)