Skip to content

Commit eea8ade

Browse files
authored
Merge pull request #326 from vishnoianil/podman-deployment
Add podman/docker compose file to start the local UI stack
2 parents 0a2ed73 + 062d1d8 commit eea8ade

File tree

6 files changed

+78
-4
lines changed

6 files changed

+78
-4
lines changed

Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ps-image: Containerfile.ps ## Build continaer image for the pathservice
5757
$(CMD_PREFIX) docker build -f Containerfile.ps -t ghcr.io/instructlab/ui/pathservice:$(TAG) .
5858
$(CMD_PREFIX) docker tag ghcr.io/instructlab/ui/pathservice:$(TAG) ghcr.io/instructlab/ui/pathservice:main
5959

60-
##@ Local Dev - Run the stack (UI and PathService) on your local machine
60+
##@ Local Dev - Local machine based deployment of the UI stack
6161
.PHONY: stop-dev-local
6262
stop-dev-local: ## Stop the npm and pathservice local instances
6363
$(CMD_PREFIX) echo "Stopping ui and pathservice..."
@@ -72,6 +72,25 @@ start-dev-local: ## Start the npm and pathservice local instances
7272
$(CMD_PREFIX) npm run dev & echo $$! > ui.pid
7373
$(CMD_PREFIX) echo "Development environment started."
7474

75+
##@ Podman Dev - Podman desktop based Deployment of the UI stack
76+
.PHONY: stop-dev-podman
77+
stop-dev-podman: ## Stop UI development stack running in podman
78+
$(CMD_PREFIX) echo "Deleting UI development stack running in podman..."
79+
$(CMD_PREFIX) podman-compose -f ./deploy/compose/ui-compose.yml down
80+
$(CMD_PREFIX) echo "Development environment deleted."
81+
82+
.PHONY: start-dev-podman
83+
start-dev-podman: ## Start UI development stack in podman
84+
$(CMD_PREFIX) echo "Deploying UI development stack using compose..."
85+
$(CMD_PREFIX) if [ ! -f .env ]; then \
86+
echo "Please create a .env file in the root of the project." ; \
87+
exit 1 ; \
88+
fi
89+
90+
$(CMD_PREFIX) yes | cp -rf .env ./deploy/compose/.env
91+
$(CMD_PREFIX) podman-compose -f ./deploy/compose/ui-compose.yml up -d
92+
$(CMD_PREFIX) echo "Development environment started."
93+
7594
##@ Kubernetes - Kind cluster based dev environment
7695
.PHONY: check-kind
7796
check-kind:

deploy/compose/ui-compose.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: '5.1'
2+
3+
services:
4+
pathservice:
5+
image: ghcr.io/instructlab/ui/pathservice:main
6+
pull_policy: always
7+
deploy:
8+
replicas: 1
9+
restart_policy:
10+
condition: always
11+
resources:
12+
limits:
13+
cpus: '0.1'
14+
memory: 200M
15+
reservations:
16+
cpus: '0.1'
17+
memory: 200M
18+
ports:
19+
- "4000:4000"
20+
21+
ui:
22+
image: ghcr.io/instructlab/ui/ui:main
23+
pull_policy: always
24+
env_file:
25+
- .env
26+
deploy:
27+
replicas: 1
28+
restart_policy:
29+
condition: always
30+
resources:
31+
limits:
32+
cpus: '0.1'
33+
memory: 200M
34+
reservations:
35+
cpus: '0.1'
36+
memory: 200M
37+
ports:
38+
- "3000:3000"

src/app/api/envConfig/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export async function GET() {
1414
MERLINITE_MODEL_NAME: process.env.IL_MERLINITE_MODEL_NAME || '',
1515
UPSTREAM_REPO_OWNER: process.env.NEXT_PUBLIC_TAXONOMY_REPO_OWNER || '',
1616
UPSTREAM_REPO_NAME: process.env.NEXT_PUBLIC_TAXONOMY_REPO || '',
17-
DEPLOYMENT_TYPE: process.env.IL_UI_DEPLOYMENT || ''
17+
DEPLOYMENT_TYPE: process.env.IL_UI_DEPLOYMENT || '',
18+
EXPERIMENTAL_FEATURES: process.env.NEXT_PUBLIC_EXPERIMENTAL_FEATURES || ''
1819
};
1920

2021
return NextResponse.json(envConfig);

src/app/api/tree/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import axios from 'axios';
33
import { NextRequest, NextResponse } from 'next/server';
44

55
const DEPLOYMENT = process.env.IL_UI_DEPLOYMENT!;
6+
const EXPERIMENTAL_FEATURES = process.env.NEXT_PUBLIC_EXPERIMENTAL_FEATURES || '';
67

78
export async function POST(req: NextRequest) {
89
const body = await req.json();
910
const { root_path, dir_name } = body;
1011

1112
try {
1213
let apiBaseUrl = 'http://pathservice:4000/tree/';
13-
if (DEPLOYMENT === 'dev') {
14+
if (DEPLOYMENT === 'dev' && EXPERIMENTAL_FEATURES !== 'true') {
1415
apiBaseUrl = 'http://localhost:4000/tree/';
1516
}
1617
const response = await axios.get<string[]>(apiBaseUrl + root_path, {

src/components/AppLayout.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { Spinner } from '@patternfly/react-core/dist/dynamic/components/Spinner'
2727
import UserMenu from './UserMenu/UserMenu';
2828
import { useSession } from 'next-auth/react';
2929
import { useTheme } from '../context/ThemeContext';
30+
import { useState } from 'react';
3031

3132
interface IAppLayout {
3233
children: React.ReactNode;
@@ -41,9 +42,21 @@ type Route = {
4142
const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
4243
const { theme } = useTheme();
4344
const { data: session, status } = useSession();
45+
const [isExperimentalEnabled, setExperimental] = useState(false);
46+
4447
const router = useRouter();
4548
const pathname = usePathname();
4649

50+
React.useEffect(() => {
51+
// Fetch the experimental feature flag
52+
const fetchExperimentalFeature = async () => {
53+
const res = await fetch('/api/envConfig');
54+
const envConfig = await res.json();
55+
setExperimental(envConfig.EXPERIMENTAL_FEATURES === 'true');
56+
};
57+
fetchExperimentalFeature();
58+
}, []);
59+
4760
React.useEffect(() => {
4861
if (status === 'loading') return; // Do nothing while loading
4962
if (!session && pathname !== '/login') {
@@ -59,7 +72,7 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
5972
return null; // Return nothing if not authenticated to avoid flicker
6073
}
6174

62-
const isExperimentalEnabled = process.env.NEXT_PUBLIC_EXPERIMENTAL_FEATURES === 'true';
75+
//const isExperimentalEnabled = process.env.NEXT_PUBLIC_EXPERIMENTAL_FEATURES === 'true';
6376

6477
// Only log if experimental features are enabled
6578
if (isExperimentalEnabled) {

src/components/Dashboard/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const Index: React.FunctionComponent = () => {
6161
}
6262
setIsFirstPullDone(true);
6363
setIsLoading(false);
64+
} else {
65+
setIsLoading(false);
6466
}
6567
}, [session?.accessToken]);
6668

0 commit comments

Comments
 (0)