Skip to content

Commit b92dd52

Browse files
authored
Devops 1 (#20)
* fix: add support for Darwin OS for torch library * Fix: adding new entrypoint for process * fix adding correct ports * fix adding correct ports * feat: initial GH workflow
1 parent 181ab61 commit b92dd52

File tree

5 files changed

+100
-9
lines changed

5 files changed

+100
-9
lines changed

.github/workflows/deployment.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: deployment
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch to deploy'
8+
required: true
9+
default: 'main'
10+
11+
jobs:
12+
ssh-test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Deploy LangBuilder & OpenWebUI via SSH
19+
uses: appleboy/ssh-action@v1.0.3
20+
with:
21+
host: 54.221.139.4
22+
username: ubuntu
23+
key: ${{ secrets.DEV_SSH_KEY }}
24+
script: |
25+
set -e
26+
export BRANCH="${{ github.event.inputs.branch || 'devops-1' }}"
27+
export REPO_DIR="/home/ubuntu/cg_langbuilder/LangBuilder"
28+
export OPENWEBUI_DIR="$REPO_DIR/openwebui"
29+
export OPENWEBUI_BACKEND_DIR="$OPENWEBUI_DIR/backend"
30+
export LANGBUILDER_DIR="$REPO_DIR/langbuilder"
31+
32+
cd "$REPO_DIR"
33+
git stash
34+
git fetch origin
35+
git checkout "$BRANCH"
36+
git pull origin "$BRANCH"
37+
38+
# Limpiar procesos previos
39+
pkill -f "open-webui" || true
40+
pkill -f "make run_cli" || true
41+
42+
cd "$OPENWEBUI_DIR"
43+
npm install --legacy-peer-deps
44+
npm run build
45+
46+
cd "$OPENWEBUI_BACKEND_DIR"
47+
source ~/miniconda3/etc/profile.d/conda.sh
48+
conda activate open-webui
49+
nohup bash dev.sh > /tmp/openwebui_backend.log 2>&1 &
50+
conda deactivate
51+
52+
cd "$LANGBUILDER_DIR"
53+
nohup make run_cli > /tmp/langbuilder.log 2>&1 &
54+
55+
echo "Deploy completo en branch $BRANCH"
56+
tail -n 20 /tmp/openwebui_backend.log || true
57+
tail -n 20 /tmp/langbuilder.log || true

langbuilder/Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ run_cli: install_frontend install_backend build_frontend ## run the CLI
204204
@uv run langbuilder run \
205205
--frontend-path $(path) \
206206
--log-level $(log_level) \
207-
--host $(host) \
208-
--port $(port) \
209207
$(if $(env),--env-file $(env),) \
210208
$(if $(filter false,$(open_browser)),--no-open-browser)
211209

@@ -248,8 +246,14 @@ backend: setup_env ## run the backend in development mode
248246
echo "$(RED)Error: Virtual environment not found. Please run 'uv venv' first.$(NC)"; \
249247
exit 1; \
250248
fi
251-
@echo "Ensuring PyTorch CPU is installed..."
252-
@uv pip install --extra-index-url https://download.pytorch.org/whl/cpu torch==2.9.1+cpu torchvision==0.24.1+cpu
249+
@echo "Ensuring PyTorch is installed..."
250+
@if [ "$$(uname)" = "Darwin" ] || [ "$$(uname -s)" = "Darwin" ] || [[ "$$(uname -a)" == *"Darwin"* ]]; then \
251+
echo "macOS detected, installing standard PyTorch..."; \
252+
uv pip install torch==2.9.1 torchvision==0.24.1; \
253+
else \
254+
echo "Linux detected, installing CPU PyTorch..."; \
255+
uv pip install --extra-index-url https://download.pytorch.org/whl/cpu torch==2.9.1+cpu torchvision==0.24.1+cpu; \
256+
fi
253257
ifdef login
254258
@echo "Running backend with autologin=$(login)";
255259
LANGBUILDER_AUTO_LOGIN=$(login) uv run uvicorn \

openwebui/backend/dev.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export CORS_ALLOW_ORIGIN="http://localhost:5173;http://localhost:8080"
2-
PORT="${PORT:-8080}"
1+
export CORS_ALLOW_ORIGIN="${CORS_ALLOW_ORIGIN:-*}"
2+
PORT="${PORT:-8767}"
33
uvicorn open_webui.main:app --port $PORT --host 0.0.0.0 --forwarded-allow-ips '*' --reload

openwebui/src/lib/constants.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
import { browser, dev } from '$app/environment';
1+
import { browser } from '$app/environment';
22
// import { version } from '../../package.json';
33

44
export const APP_NAME = 'ActionBridge';
55

6-
export const WEBUI_HOSTNAME = browser ? (dev ? `${location.hostname}:8767` : ``) : '';
7-
export const WEBUI_BASE_URL = browser ? (dev ? `http://${WEBUI_HOSTNAME}` : ``) : ``;
6+
// Leer ENV desde import.meta.env (expuesto por Vite)
7+
const ENV = import.meta.env.ENV;
8+
const DEV_BACKEND_DOMAIN = 'dev-langbuilder-app.cloudgeometry.com';
9+
const PROD_BACKEND_DOMAIN = 'langbuilder-app.cloudgeometry.com';
10+
11+
export const WEBUI_HOSTNAME = browser
12+
? ENV === 'dev'
13+
? DEV_BACKEND_DOMAIN
14+
: ENV === 'prod'
15+
? PROD_BACKEND_DOMAIN
16+
: location.host
17+
: '';
18+
19+
export const WEBUI_BASE_URL = browser
20+
? ENV === 'dev' || ENV === 'prod'
21+
? `https://${WEBUI_HOSTNAME}`
22+
: `${location.protocol}//${location.host}`
23+
: '';
24+
825
export const WEBUI_API_BASE_URL = `${WEBUI_BASE_URL}/api/v1`;
926

1027
export const OLLAMA_API_BASE_URL = `${WEBUI_BASE_URL}/ollama`;
@@ -13,6 +30,10 @@ export const AUDIO_API_BASE_URL = `${WEBUI_BASE_URL}/api/v1/audio`;
1330
export const IMAGES_API_BASE_URL = `${WEBUI_BASE_URL}/api/v1/images`;
1431
export const RETRIEVAL_API_BASE_URL = `${WEBUI_BASE_URL}/api/v1/retrieval`;
1532

33+
// These are defined in vite.config.ts via defineConfig.define
34+
declare const APP_VERSION: string;
35+
declare const APP_BUILD_HASH: string;
36+
1637
export const WEBUI_VERSION = APP_VERSION;
1738
export const WEBUI_BUILD_HASH = APP_BUILD_HASH;
1839
export const REQUIRED_OLLAMA_VERSION = '0.1.16';

openwebui/vite.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ export default defineConfig({
1616
]
1717
})
1818
],
19+
server: {
20+
allowedHosts: [
21+
'localhost',
22+
'127.0.0.1',
23+
'dev-langbuilder-app.cloudgeometry.com',
24+
'langbuilder-app.cloudgeometry.com',
25+
'.cloudgeometry.com'
26+
]
27+
},
1928
define: {
2029
APP_VERSION: JSON.stringify(process.env.npm_package_version),
2130
APP_BUILD_HASH: JSON.stringify(process.env.APP_BUILD_HASH || 'dev-build')

0 commit comments

Comments
 (0)