Skip to content

Commit 4575815

Browse files
Feat/add docker to workflows (#149)
* Add Docker build and push to workflows Updated upload-pypi-dev and upload-pypi to build and push a docker image with the most recent version of LLMstudio (including dev releases) to tensoropsai dockerhub. * Fix some lint issues
1 parent 2dc0229 commit 4575815

File tree

3 files changed

+102
-3
lines changed

3 files changed

+102
-3
lines changed

.github/workflows/upload-pypi-dev.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Upload Python package to PyPI as dev pre-release
1+
name: Upload Python package to PyPI as dev release and build/push Docker image.
22

33
on:
44
workflow_dispatch:
@@ -39,3 +39,48 @@ jobs:
3939
git add pyproject.toml
4040
git commit -m "[fix] bump prerelease version in pyproject.toml"
4141
git push
42+
43+
# Wait for PyPI to update
44+
- name: Wait for PyPI to update
45+
run: |
46+
VERSION=$(poetry version --short)
47+
echo "Checking for llmstudio==$VERSION on PyPI..."
48+
for i in {1..10}; do
49+
if python -m pip install llmstudio==${VERSION} --dry-run >/dev/null 2>&1; then
50+
echo "Package llmstudio==${VERSION} is available on PyPI."
51+
break
52+
else
53+
echo "Package llmstudio==${VERSION} not available yet. Waiting 15 seconds..."
54+
sleep 15
55+
fi
56+
if [ $i -eq 10 ]; then
57+
echo "Package did not become available in time."
58+
exit 1
59+
fi
60+
done
61+
62+
# Docker build and push section
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v2
65+
66+
- name: Log in to Docker Hub
67+
uses: docker/login-action@v2
68+
with:
69+
username: ${{ secrets.DOCKER_USERNAME }}
70+
password: ${{ secrets.DOCKER_PASSWORD }}
71+
72+
- name: Extract version for tagging Docker image
73+
id: get_version
74+
run: |
75+
echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV
76+
77+
- name: Build and tag Docker image
78+
run: |
79+
docker build \
80+
--build-arg LLMSTUDIO_VERSION=${{ env.VERSION }} \
81+
-t tensoropsai/llmstudio:${{ env.VERSION }} \
82+
.
83+
84+
- name: Push Docker image to Docker Hub
85+
run: |
86+
docker push tensoropsai/llmstudio:${{ env.VERSION }}

.github/workflows/upload-pypi.yml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Upload Python package to PyPI
1+
name: Upload Python package to PyPI and build/push Docker images.
22

33
on:
44
push:
@@ -11,23 +11,77 @@ jobs:
1111
deploy:
1212
runs-on: ubuntu-latest
1313
steps:
14+
# Checkout the code
1415
- name: Checkout code
1516
uses: actions/checkout@v2
1617

18+
# Set up Python environment
1719
- name: Set up Python
1820
uses: actions/setup-python@v2
1921
with:
2022
python-version: "3.x"
2123

24+
# Install Poetry
2225
- name: Install Poetry
2326
run: |
2427
curl -sSL https://install.python-poetry.org | python3 -
2528
29+
# Configure Poetry with PyPI token
2630
- name: Configure Poetry
2731
run: |
2832
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
2933
34+
# Build and publish package to PyPI
3035
- name: Build and publish to PyPI
3136
run: |
3237
poetry build
3338
poetry publish
39+
40+
# Extract the new version number from pyproject.toml
41+
- name: Extract version for tagging Docker image
42+
run: |
43+
echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV
44+
45+
# Wait for the package to become available on PyPI
46+
- name: Wait for PyPI to update
47+
run: |
48+
echo "Checking for llmstudio==${{ env.VERSION }} on PyPI..."
49+
for i in {1..10}; do
50+
if python -m pip install llmstudio==${{ env.VERSION }} --dry-run >/dev/null 2>&1; then
51+
echo "Package llmstudio==${{ env.VERSION }} is available on PyPI."
52+
break
53+
else
54+
echo "Package llmstudio==${{ env.VERSION }} not available yet. Waiting 15 seconds..."
55+
sleep 15
56+
fi
57+
if [ $i -eq 10 ]; then
58+
echo "Package did not become available in time."
59+
exit 1
60+
fi
61+
done
62+
63+
# Set up Docker Buildx
64+
- name: Set up Docker Buildx
65+
uses: docker/setup-buildx-action@v2
66+
67+
# Log in to Docker Hub
68+
- name: Log in to Docker Hub
69+
uses: docker/login-action@v2
70+
with:
71+
username: ${{ secrets.DOCKER_USERNAME }}
72+
password: ${{ secrets.DOCKER_PASSWORD }}
73+
74+
# Build and tag Docker images with both :latest and :[NEW_VERSION]
75+
- name: Build and tag Docker images
76+
run: |
77+
docker build \
78+
--build-arg LLMSTUDIO_VERSION=${{ env.VERSION }} \
79+
-t tensoropsai/llmstudio:latest \
80+
-t tensoropsai/llmstudio:${{ env.VERSION }} \
81+
.
82+
83+
# Push both Docker images to Docker Hub
84+
- name: Push Docker images to Docker Hub
85+
run: |
86+
docker push tensoropsai/llmstudio:${{ env.VERSION }}
87+
docker push tensoropsai/llmstudio:latest

llmstudio/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ def server(ui):
3434

3535

3636
if __name__ == "__main__":
37-
main()
37+
main()

0 commit comments

Comments
 (0)