Skip to content

Commit 86e871f

Browse files
authored
init(frontend) - initializing POC frontend application in compass (#46)
- deploy frontend to gcp bucket - separate out compass endpoint environment variable
1 parent 3664ac0 commit 86e871f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4911
-18
lines changed

.github/workflows/deploy-backend.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
cache: 'pip' # caching pip dependencies
4343
- name: Install python packages
4444
run: pip install -r requirements.txt
45-
working-directory: iac
45+
working-directory: iac/backend
4646
- name: Setup google-cloud-auth
4747
uses: google-github-actions/[email protected]
4848
with:
@@ -54,7 +54,7 @@ jobs:
5454
id: pulumi
5555
uses: pulumi/actions@v5
5656
with:
57-
work-dir: iac
57+
work-dir: iac/backend
5858
command: up
5959
stack-name: tabiya-tech/compass-backend/${{ inputs.target-environment }}
6060
env:
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Tabiya Compass Frontend Deploy
2+
on:
3+
workflow_call:
4+
inputs:
5+
target-environment:
6+
required: true
7+
type: string
8+
backendRestApiURLBase:
9+
required: true
10+
type: string
11+
outputs:
12+
version-info:
13+
description: 'The frontend version info'
14+
value: ${{ jobs.build.outputs.version-info }}
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
environment: ${{ inputs.target-environment }}
20+
outputs:
21+
version-info: ${{ steps.setVersionInfo.outputs.version-info }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
- name: Set Version Info
26+
id: setVersionInfo
27+
run: |
28+
./pipeline/setVersionInfo.sh frontend/public/data/version.json
29+
cat frontend/public/data/version.json
30+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
31+
echo "version-info<<$EOF" >> "$GITHUB_OUTPUT"
32+
echo "$(cat ./frontend/public/data/version.json)" >> "$GITHUB_OUTPUT"
33+
echo "$EOF" >> "$GITHUB_OUTPUT"
34+
- name: Use Node.js 20.x
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: 20.x
38+
cache: 'yarn'
39+
cache-dependency-path: frontend/yarn.lock
40+
- name: Install node packages
41+
run: yarn install
42+
working-directory: frontend
43+
- name: build
44+
run: yarn run build
45+
working-directory: frontend
46+
env:
47+
NEXT_PUBLIC_COMPASS_URL: ${{ inputs.backendRestApiURLBase }}
48+
NEXT_PUBLIC_COMPASS_ENDPOINT: '/conversation'
49+
- name: Setup python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: '3.11'
53+
cache: 'pip' # caching pip dependencies
54+
- name: Install python packages
55+
run: pip install -r requirements.txt
56+
working-directory: iac/frontend
57+
- name: Setup google-cloud-auth
58+
uses: google-github-actions/[email protected]
59+
with:
60+
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON }}
61+
- name: Deploy frontend
62+
id: pulumi
63+
uses: pulumi/actions@v5
64+
with:
65+
work-dir: iac/frontend
66+
command: up
67+
stack-name: tabiya-tech/compass-frontend/${{ inputs.target-environment }}
68+
env:
69+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
70+
MONGODB_URI: ${{ secrets.MONGODB_URI }}
71+
NEXT_PUBLIC_COMPASS_URL: ${{ inputs.backendRestApiURLBase }}
72+
- name: Show frontend URL
73+
run: echo "frontend-url<<${{ steps.pulumi.outputs.bucket_url }}"

.github/workflows/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ jobs:
1313
secrets: inherit
1414
with:
1515
target-environment: dev
16+
test-frontend:
17+
uses: ./.github/workflows/test-frontend.yml
18+
secrets: inherit
19+
with:
20+
target-environment: dev
1621
deploy-backend:
1722
# This job will only run if the push event is on the main branch or the commit message contains '[pulumi up]'
1823
if: github.event_name == 'push' && ( github.ref == 'refs/heads/main' || contains(github.event.head_commit.message, '[pulumi up]'))
@@ -21,6 +26,15 @@ jobs:
2126
secrets: inherit
2227
with:
2328
target-environment: dev
29+
deploy-frontend:
30+
# This job will only run if the push event is on the main branch or the commit message contains '[pulumi up]'
31+
if: github.event_name == 'push' && ( github.ref == 'refs/heads/main' || contains(github.event.head_commit.message, '[pulumi up]'))
32+
needs: [ test-frontend, deploy-backend ]
33+
uses: ./.github/workflows/deploy-frontend.yml
34+
secrets: inherit
35+
with:
36+
target-environment: dev
37+
backendRestApiURLBase: ${{ needs.deploy-backend.outputs.backendRestApiURLBase }}
2438
smoke-test-backend:
2539
needs: [ deploy-backend ]
2640
uses: ./.github/workflows/smoke-test-version.yml
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Tabiya compass frontend test
2+
on:
3+
workflow_call:
4+
inputs:
5+
target-environment:
6+
required: true
7+
type: string
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
environment: ${{ inputs.target-environment }}
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
- name: Use Node.js 20.x
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 20.x
19+
cache: 'yarn'
20+
cache-dependency-path: frontend/yarn.lock
21+
- name: Install node packages
22+
run: yarn install
23+
working-directory: frontend
24+
- name: Lint
25+
run: yarn run lint
26+
working-directory: frontend

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ their skills and interests based on their lived experiences.
1515

1616
- **[Backend](backend)**: Explore the Backend directory for detailed insights about the backend project.
1717

18+
- **[Frontend](frontend)**: Explore the Frontend directory for detailed insights about the frontend project.
19+
1820
- **[Infrastructure As Code (IaC)](iac)**: Explore the Infrastructure as code(IAC) directory for detailed insights about
1921
the infrastructure-as-code components.
2022

frontend/.env.development

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NEXT_PUBLIC_COMPASS_URL=http://0.0.0.0:8080
2+
NEXT_PUBLIC_COMPASS_ENDPOINT=/conversation

frontend/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

frontend/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
38+
.env
39+
.env.development

frontend/.prettierrc.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"printWidth": 120,
3+
"trailingComma": "es5",
4+
"tabWidth": 2,
5+
"semi": true,
6+
"singleQuote": false,
7+
"jsxSingleQuote": false,
8+
"bracketSpacing": true,
9+
"jsxBracketSameLine": false,
10+
"arrowParens": "always",
11+
"htmlWhitespaceSensitivity": "css",
12+
"endOfLine": "lf"
13+
}

frontend/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Jakob Hoeg Mørk
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)