Skip to content

Commit 38060f4

Browse files
committed
chore: Embedded Chat Deploy (#35)
* Dockerfile for embedded chat * Nginx config for embedded chat * GitHub workflow for embedded chat * Prettier
1 parent 1c84407 commit 38060f4

File tree

13 files changed

+339
-175
lines changed

13 files changed

+339
-175
lines changed

.github/workflows/embedded-chat.yaml

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: embedded-chat
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- 'packages/embedded-chat/**'
8+
branches:
9+
- main
10+
tags:
11+
- "v*.*.*"
12+
pull_request:
13+
paths:
14+
- 'packages/embedded-chat/**'
15+
branches:
16+
- main
17+
18+
jobs:
19+
lint:
20+
runs-on: ubuntu-latest
21+
name: Check for Linting Errors
22+
defaults:
23+
run:
24+
working-directory: packages/embedded-chat
25+
steps:
26+
- name: Checkout Repository
27+
uses: actions/checkout@v3
28+
with:
29+
ref: ${{ github.event.pull_request.head.ref }}
30+
31+
- name: Setup NodeJS
32+
uses: actions/setup-node@v3
33+
with:
34+
node-version: 22
35+
36+
- name: NPM Install
37+
run: npm install --only=dev
38+
shell: bash
39+
40+
- name: Check for Linting Issues
41+
run: npm run prettier
42+
43+
build:
44+
runs-on: ubuntu-latest
45+
name: Build Code
46+
defaults:
47+
run:
48+
working-directory: packages/embedded-chat
49+
steps:
50+
- name: Checkout Repository
51+
uses: actions/checkout@v3
52+
53+
- name: Setup NodeJS
54+
uses: actions/setup-node@v3
55+
with:
56+
node-version: 22
57+
58+
- name: NPM Install
59+
run: npm install
60+
shell: bash
61+
62+
- name: Build
63+
run: npm run build
64+
65+
docker:
66+
name: Docker Build and Push
67+
runs-on: ubuntu-latest
68+
defaults:
69+
run:
70+
working-directory: packages/embedded-chat
71+
steps:
72+
- uses: docker/setup-qemu-action@v2
73+
- uses: docker/setup-buildx-action@v2
74+
75+
- name: Checkout repository
76+
uses: actions/checkout@v3
77+
78+
- name: Docker Tags
79+
id: meta
80+
uses: docker/metadata-action@v4
81+
with:
82+
images: |
83+
hicsail/preaa-embedded-chat
84+
tags: |
85+
type=ref,event=branch
86+
type=semver,pattern={{version}}
87+
type=semver,pattern={{major}}
88+
type=semver,pattern={{major}}.{{minor}}
89+
90+
- name: Login to Docker Hub
91+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
92+
uses: docker/login-action@v2
93+
with:
94+
username: ${{ secrets.DOCKERHUB_USERNAME }}
95+
password: ${{ secrets.DOCKERHUB_TOKEN }}
96+
97+
- name: Build & Push Docker Build
98+
uses: docker/build-push-action@v4
99+
with:
100+
push: ${{ github.event_name != 'pull_request' }}
101+
context: ./packages/embedded-chat
102+
file: ./packages/embedded-chat/Dockerfile
103+
tags: ${{ steps.meta.outputs.tags }}
104+
labels: ${{ steps.meta.outputs.labels }}
105+
cache-from: type=gha,scope=gateway
106+
cache-to: type=gha,mode=max,scope=gateway
107+
build-args: |
108+
VITE_BACKEND_BASE_URL=${{ secrets.HELPER_BACKEND_URL }}
109+
110+
deployment:
111+
runs-on: ubuntu-latest
112+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
113+
needs: [docker]
114+
steps:
115+
- name: Push to Staging
116+
uses: fjogeleit/http-request-action@v1
117+
with:
118+
method: "POST"
119+
url: ${{ secrets.PORTAINER_WEBHOOK }}
120+
preventFailureOnNoResponse: true

deploy/portainer/docker-compose.yml

+16-8
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,6 @@ services:
201201
- ../../stack.env
202202
- stack.env
203203

204-
admin-client:
205-
image: hicsail/preaa-admin-client:main
206-
pull_policy: always
207-
container_name: portainer-admin-client
208-
restart: unless-stopped
209-
ports:
210-
- "3010:80"
211-
212204
chat-client:
213205
image: hicsail/preaa-chat-client:main
214206
pull_policy: always
@@ -220,6 +212,22 @@ services:
220212
- ../../stack.env
221213
- stack.env
222214

215+
admin-client:
216+
image: hicsail/preaa-admin-client:main
217+
pull_policy: always
218+
container_name: portainer-admin-client
219+
restart: unless-stopped
220+
ports:
221+
- "3016:80"
222+
223+
embedded-chat:
224+
image: hicsail/preaa-embedded-chat:main
225+
pull_policy: always
226+
container_name: portainer-embedded-chat
227+
restart: unless-stopped
228+
ports:
229+
- "3017:80"
230+
223231
volumes:
224232
portainer-langflow-data:
225233
portainer-langflow-components:

packages/embedded-chat/.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"printWidth": 120,
3+
"singleQuote": true,
4+
"trailingComma": "none"
5+
}

packages/embedded-chat/Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:22-alpine AS builder
2+
3+
ARG VITE_BACKEND_BASE_URL
4+
5+
ENV VITE_BACKEND_BASE_URL=${VITE_BACKEND_BASE_URL}
6+
7+
WORKDIR /usr/src/app
8+
9+
COPY . .
10+
11+
RUN npm install
12+
RUN npm run build
13+
14+
FROM nginx:1.27.4-alpine AS prod
15+
16+
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html
17+
COPY nginx.conf /etc/nginx/conf.d/default.conf
18+
19+
CMD nginx -g "daemon off;"

packages/embedded-chat/nginx.conf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
server {
2+
listen 80;
3+
4+
location / {
5+
root /usr/share/nginx/html;
6+
index index.html index.htm;
7+
try_files $uri $uri/ /index.html =404;
8+
}
9+
}

packages/embedded-chat/package-lock.json

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/embedded-chat/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"dev": "vite",
88
"build": "tsc -b && vite build",
99
"lint": "eslint .",
10-
"preview": "vite preview"
10+
"preview": "vite preview",
11+
"prettier": "prettier -l \"src/**/*.ts(x)\"",
12+
"prettier:fix": "prettier -wl \"src/**/*.ts(x)\""
1113
},
1214
"dependencies": {
1315
"@emotion/react": "^11.14.0",
@@ -29,6 +31,7 @@
2931
"eslint-plugin-react-hooks": "^5.1.0",
3032
"eslint-plugin-react-refresh": "^0.4.19",
3133
"globals": "^15.15.0",
34+
"prettier": "^3.5.3",
3235
"typescript": "~5.7.2",
3336
"typescript-eslint": "^8.24.1",
3437
"vite": "^6.2.0"

0 commit comments

Comments
 (0)