forked from gptme/gptme
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (157 loc) · 5.41 KB
/
build.yml
File metadata and controls
179 lines (157 loc) · 5.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Build
on:
push:
branches: [ master ]
tags:
- 'v*'
pull_request:
branches: [ master ]
jobs:
build-docker:
name: Docker
runs-on: ubuntu-latest
env:
SHOULD_PUSH: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' }}
permissions:
packages: write
steps:
- uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
if: env.SHOULD_PUSH == 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set environment variables
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
# Sanitize the ref name to be used as a Docker tag
SANITIZED_REF_NAME=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
echo "SANITIZED_REF_NAME=${SANITIZED_REF_NAME}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
# First build the base image locally (needed for subsequent builds)
- name: Build Docker image (base)
uses: docker/build-push-action@v6
with:
tags: gptme:latest
file: ./scripts/Dockerfile
context: .
push: false
# Push base image to registry if on master/tag
- name: Push Docker image (base)
uses: docker/build-push-action@v6
if: env.SHOULD_PUSH == 'true'
with:
tags: |
ghcr.io/${{ env.OWNER_LC }}/gptme:latest
ghcr.io/${{ env.OWNER_LC }}/gptme:${{ env.SANITIZED_REF_NAME }}
file: ./scripts/Dockerfile
context: .
push: true
# Build and push eval image
- name: Build and push Docker image (server)
uses: docker/build-push-action@v6
with:
tags: |
ghcr.io/${{ env.OWNER_LC }}/gptme-server:latest
ghcr.io/${{ env.OWNER_LC }}/gptme-server:${{ env.SANITIZED_REF_NAME }}
file: ./scripts/Dockerfile.server
context: .
build-args: |
BASE=gptme:latest
push: ${{ env.SHOULD_PUSH }}
# Build and push eval image
- name: Build and push Docker image (eval)
uses: docker/build-push-action@v6
with:
tags: |
ghcr.io/${{ env.OWNER_LC }}/gptme-eval:latest
ghcr.io/${{ env.OWNER_LC }}/gptme-eval:${{ env.SANITIZED_REF_NAME }}
file: ./scripts/Dockerfile.eval
context: .
push: ${{ env.SHOULD_PUSH }}
# Now the full eval image
# NOTE: takes a long time and leads to a big (1GB+) image
#- name: Build and push Docker image (eval-full)
# uses: docker/build-push-action@v6
# with:
# tags: |
# ghcr.io/${{ env.OWNER_LC }}/gptme-eval-full:latest
# ghcr.io/${{ env.OWNER_LC }}/gptme-eval-full:${{ env.SANITIZED_REF_NAME }}
# file: ./scripts/Dockerfile.eval
# context: .
# push: true
# build-args: |
# RUST=yes
# BROWSER=yes
# Report and check image sizes
- name: Check image sizes
run: |
echo "## Docker Image Sizes" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Image | Size |" >> $GITHUB_STEP_SUMMARY
echo "|-------|------|" >> $GITHUB_STEP_SUMMARY
for img in gptme:latest ghcr.io/${OWNER_LC}/gptme-server:latest ghcr.io/${OWNER_LC}/gptme-eval:latest; do
SIZE=$(docker image inspect "$img" --format '{{.Size}}' 2>/dev/null || echo "0")
SIZE_MB=$((SIZE / 1024 / 1024))
echo "| $img | ${SIZE_MB}MB |" >> $GITHUB_STEP_SUMMARY
echo "$img: ${SIZE_MB}MB"
# Warn if base image exceeds 900MB (leave headroom, but catch regressions)
if [ "$img" = "gptme:latest" ] && [ "$SIZE_MB" -gt 900 ]; then
echo "::warning::Base image $img is ${SIZE_MB}MB (limit: 900MB)"
fi
done
build-pyinstaller:
name: PyInstaller binaries on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest] # windows-latest
python_version: ['3.13']
steps:
- uses: actions/checkout@v6
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
cache: 'poetry'
#cache-dependency-path: |
# pyproject.toml
# poetry.lock
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y python3-dev build-essential libffi-dev
- name: Install dependencies
run: |
make build
poetry install --extras server --extras pyinstaller --with dev
- name: Build PyInstaller executable
run: make build-server-exe
- name: Test executable (Unix)
if: runner.os != 'Windows'
run: |
./dist/gptme-server --help
echo "✅ gptme-server --help executed successfully"
- name: Test executable (Windows)
if: runner.os == 'Windows'
run: |
.\dist\gptme-server.exe --help
echo "✅ gptme-server.exe --help executed successfully"
- name: Upload executable artifact
uses: actions/upload-artifact@v6
with:
name: gptme-server-${{ matrix.os }}
path: |
dist/gptme-server*
retention-days: 7