Skip to content

Commit dfb0adc

Browse files
authored
Add deploy action (#72)
* Add deploy action * Fix typo * Fix can not get pkg from git * Delete old files before cp * Increase command timeout * Updating ollama for gemma3n * Fix docker build command * Add OLLAMA_HOST for embedding * Revert "Add OLLAMA_HOST for embedding" This reverts commit 4ac9c1c. * Fix embedding ollama url * Fix config key ollama embed * Add missing key * Only run on main
1 parent c9e6fb0 commit dfb0adc

7 files changed

Lines changed: 77 additions & 25 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy Server
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Copy repo to server
16+
uses: appleboy/scp-action@v1
17+
with:
18+
host: ${{ vars.SERVER_HOST }}
19+
username: ${{ vars.SERVER_USER }}
20+
key: ${{ secrets.PRIVATE_KEY }}
21+
source: "."
22+
target: "/home/${{ vars.SERVER_USER }}/repo"
23+
24+
- name: Execute on server
25+
uses: appleboy/ssh-action@v1
26+
with:
27+
host: ${{ vars.SERVER_HOST }}
28+
username: ${{ vars.SERVER_USER }}
29+
key: ${{ secrets.PRIVATE_KEY }}
30+
script: |
31+
# create dir if not exists
32+
mkdir GetDressed
33+
# move to the repo directory
34+
cd GetDressed
35+
# Stop compose if running
36+
docker compose -f compose.yaml -f compose.ollama.yaml down
37+
# Delete old repo
38+
rm -rf *
39+
# Copy new repo
40+
cp -r ../repo/* .
41+
# Remove copied repo
42+
rm -rf ../repo
43+
# Build containers
44+
docker compose -f compose.yaml -f compose.ollama.yaml build
45+
# Start containers
46+
docker compose -f compose.yaml -f compose.ollama.yaml up -d
47+
command_timeout: 60m

compose.ollama.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
services:
2+
api:
3+
environment:
4+
- API_BASE=http://ollama:11434
5+
6+
ollama:
7+
build:
8+
context: .
9+
dockerfile: ollama.Dockerfile
10+
deploy:
11+
resources:
12+
reservations:
13+
devices:
14+
- driver: nvidia
15+
count: 1
16+
capabilities: [gpu]
17+
ports:
18+
- "11434:11434"
19+
restart: always

compose.yaml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
11
name: getdressed
22

33
services:
4-
ollama:
5-
build:
6-
context: .
7-
dockerfile: ollama.Dockerfile
8-
deploy:
9-
resources:
10-
reservations:
11-
devices:
12-
- driver: nvidia
13-
count: all
14-
capabilities: [gpu]
15-
ports:
16-
- "11434:11434"
17-
volumes:
18-
- ollama:/root/.ollama
19-
restart: always
20-
214
api:
225
build: ./server
236
environment:
24-
- MODEL=ollama/gemma3n:e4b
25-
- API_BASE=http://ollama:11434
7+
- MODEL=ollama/gemma3n
268
ports:
27-
- "8080:80"
9+
- "8000:80"
2810
restart: always
2911

3012
pb:
@@ -36,5 +18,4 @@ services:
3618
restart: always
3719

3820
volumes:
39-
ollama:
4021
pb:

ollama.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ollama/ollama:0.9.1
2-
ARG MODELS="llama3.1 nomic-embed-text"
1+
FROM ollama/ollama:0.9.4
2+
ARG MODELS="gemma3n nomic-embed-text"
33
ENV OLLAMA_KEEP_ALIVE=24h
44
RUN ollama serve & server=$! ; sleep 5 ; for m in $MODELS ; do ollama pull $m ; done ; kill $server

server/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
MODEL=ollama/gemma3n:e4b
1+
MODEL=ollama/gemma3n
22
API_BASE=http://localhost:11434

server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.13-slim
1+
FROM python:3.13
22

33
# Install uv.
44
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

server/agents/trend_crew/src/trend_crew/crew.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
from crewai import Agent, Crew, Process, Task
24
from crewai.project import CrewBase, agent, crew, task
35
from crewai.agents.agent_builder.base_agent import BaseAgent
@@ -49,6 +51,7 @@ def trend_alchemist(self) -> Agent:
4951
# https://docs.crewai.com/concepts/tasks#overview-of-a-task
5052
@task
5153
def find_sources_task(self) -> Task:
54+
print("API_BASE:", os.getenv("API_BASE"))
5255
return Task(
5356
config=self.tasks_config['find_sources'], # type: ignore[index]
5457
tools=[
@@ -58,6 +61,7 @@ def find_sources_task(self) -> Task:
5861
provider="ollama",
5962
config=dict(
6063
model="nomic-embed-text",
64+
base_url=os.getenv("API_BASE"),
6165
)
6266
),
6367
)
@@ -76,6 +80,7 @@ def collect_trend_data_task(self) -> Task:
7680
provider="ollama",
7781
config=dict(
7882
model="nomic-embed-text",
83+
base_url=os.getenv("API_BASE"),
7984
)
8085
),
8186
)

0 commit comments

Comments
 (0)