Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/cd #114

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Ci/cd #114

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/workflows/ci/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Next.js CI/CD Pipeline

on:
push:
branches:
- main
- staging
pull_request:
branches:
- main
- staging

jobs:
# 1. Setup Job to check for correct Node and Yarn versions
setup:
runs-on: ubuntu-latest
outputs:
node-version: ${{ steps.node.outputs.node-version }}
yarn-version: ${{ steps.yarn.outputs.yarn-version }}

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup Node.js
id: node
uses: actions/setup-node@v3
with:
node-version: '18.20.4'

- name: Cache Yarn Dependencies
id: yarn
uses: actions/cache@v3
with:
path: ~/.yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

# 2. Linting Job
lint:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Run ESLint
run: yarn lint
env:
CI: true

# 3. Testing Job
test:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Run Unit Tests
run: yarn test
env:
CI: true

- name: Run End-to-End Tests
run: yarn test:e2e
env:
CI: true

# 4. Build Job
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build Next.js App
run: yarn build
env:
CI: true

# 5. Deployment Job
deploy:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build for Deployment
run: yarn build

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Build and push Docker image for 'main' branch
- name: Build and push production image
if: github.ref == 'refs/heads/main'
run: |
docker build -t andersoninc12/aibosRAG:latest .
docker push andersoninc12/aibosRAG:latest

# SSH into VPS and deploy for 'main' branch
- name: SSH into VPS and deploy for production
if: github.ref == 'refs/heads/main'
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.VPS_SSH_KEY }}

- name: Deploy to VPS (Production)
if: github.ref == 'refs/heads/main'
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} << 'EOF'
sudo docker stop aibosRAG || truels -ld
sudo docker rm -f aibosRAG || true
sudo docker rmi andersoninc12/aibosRAG:latest || true
sudo docker pull andersoninc12/aibosRAG:latest
sudo docker run --name epanet -p 8083:3000 andersoninc12/aibosRAG:latest
EOF
32 changes: 30 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@

# WORKDIR /app

# COPY . .

# RUN yarn install
# RUN yarn build

# EXPOSE 3000

# CMD ["yarn","start"]



FROM --platform=linux/amd64 node:19-bullseye-slim

# Set the working directory
WORKDIR /app

# Copy only the package.json and lock files for dependency installation
COPY package.json yarn.lock ./

# Install dependencies (for production only, to keep the image small)
RUN yarn install --frozen-lockfile --production

# Copy the rest of the application files
COPY . .

RUN yarn install
# Build the Next.js app
RUN yarn build

# Set environment variables (adjust as needed)
ENV PORT 3000
ENV NODE_ENV production

# Expose the port the app runs on
EXPOSE 3000

CMD ["yarn","start"]
# Start the application
CMD ["yarn", "start"]
23 changes: 23 additions & 0 deletions app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

node_modules
*.log
*.ts
*.tsx
__tests__


.env.local
.env.development.local
.env.test.local
.env.production.local


Dockerfile
.dockerignore


.git
.gitignore
.vscode
.idea
.DS_Store
6 changes: 4 additions & 2 deletions app/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
/*--background-end-rgb: 255, 255, 255;*/
--background-end-rgb: 0, 0, 25;

--primary-glow: conic-gradient(from 180deg at 50% 50%,
#16abff33 0deg,
Expand All @@ -34,7 +35,8 @@

--callout-rgb: 238, 240, 241;
--callout-border-rgb: 172, 175, 176;
--card-rgb: 180, 185, 188;
/*--card-rgb: 180, 185, 188;*/
--card-rgb: 0, 5, 188;
--card-border-rgb: 131, 134, 135;
}

Expand Down
12 changes: 6 additions & 6 deletions config/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { AppInfo } from '@/types/app'
import { PromptTemplate } from '../app/components/welcome/massive-component';
export const APP_ID = `${process.env.NEXT_PUBLIC_APP_ID}`
export const API_KEY = `${process.env.NEXT_PUBLIC_APP_KEY}`
export const API_URL = `${process.env.NEXT_PUBLIC_API_URL}`
export const APP_INFO: AppInfo = {
title: 'Chat APP',
description: '',
copyright: '',
title: 'Aibos Epanet',
description: 'This is the knowledge base for the Epanet Project ',
copyright: 'Aibos Inc',
privacy_policy: '',
default_language: 'en',
}

export const isShowPrompt = false
export const promptTemplate = 'I want you to act as a javascript console.'

export const isShowPrompt = true
export const promptTemplate = ''
export const API_PREFIX = '/api'

export const LOCALE_COOKIE_NAME = 'locale'
Expand Down