Skip to content

Commit

Permalink
Merge pull request #2 from lonestone/feature/cooppilot-front
Browse files Browse the repository at this point in the history
Feature/cooppilot front
  • Loading branch information
kevin-lonestone authored Nov 25, 2024
2 parents a0be436 + 2cbb238 commit 7968125
Show file tree
Hide file tree
Showing 189 changed files with 22,527 additions and 19 deletions.
1 change: 1 addition & 0 deletions .devcontainer/base-back
1 change: 1 addition & 0 deletions .devcontainer/base-front
1 change: 1 addition & 0 deletions .devcontainer/base-rag
50 changes: 50 additions & 0 deletions .devcontainer/coopilot-back/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "cooppilot-back",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
// "runArgs": [
// "--name",
// "<service-name>"
// ],
"dockerComposeFile": [
"../../docker-compose.yml"
],
"service": "cooppilot-back",
"workspaceFolder": "/workspace",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
"runServices": [
"cooppilot-back",
"back-end-db-dev"
],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
"shutdownAction": "none",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
}
},
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"Prisma.prisma"
]
}
}
}
46 changes: 46 additions & 0 deletions .devcontainer/coopilot-front/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "cooppilot-front",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
// "runArgs": [
// "--name",
// "<service-name>"
// ],
"dockerComposeFile": [
"../../docker-compose.yml"
],
"service": "cooppilot-front",
"workspaceFolder": "/workspace",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
"runServices": [
"cooppilot-front"
],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
"shutdownAction": "none",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"bradlc.vscode-tailwindcss"
]
}
}
}
59 changes: 59 additions & 0 deletions .github/workflows/deploy-coopilot-front.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy Cooppilot Front

on:
push:
branches:
- deploy/production
paths:
- "base/apps/common/**"
- "cooppilot/apps/cooppilot-front/**"
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:
name: Deploy Cooppilot Front to Netlify
runs-on: ubuntu-latest
environment: production
defaults:
run:
working-directory: ./cooppilot/apps/cooppilot-front

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN_FOR_SUBMODULE }}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.14.x"
cache: "pnpm"
cache-dependency-path: |
base/apps/common/pnpm-lock.yaml
cooppilot/apps/cooppilot-front/pnpm-lock.yaml
- name: Install dependencies
run: |
pnpm install
- name: Build
env:
VITE_BACK_END_API_ENDPOINT: "https://api.splus-cooppilot.ai.lonestone.io"
run: pnpm run build

- name: Deploy
run: |
pnpm --package=netlify-cli dlx netlify deploy \
--dir ./dist \
-a ${{ secrets.NETLIFY_PAT }} \
-s 757ef4e1-5c1f-44e6-b3bd-c1791daaf4ef \
--prod \
--message "Deploy from GitHub Actions [sha: ${{ github.sha }}]"
28 changes: 28 additions & 0 deletions .github/workflows/deploy-cooppilot-back.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy Cooppilot Back

on:
push:
branches:
- deploy/production
paths:
- "base/apps/common/**"
- "cooppilot/apps/cooppilot-back/**"
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:
name: Deploy Cooppilot Back to ECS
uses: ./.github/workflows/reusable-deploy-to-ecs.yml
with:
ecs_cluster: cooppilot-cluster
app_name: cooppilot-cooppilot-ai-back-service
build_dir: ./
dockerfile_dir: ./cooppilot/apps/cooppilot-back/
build_context: ./
aws_region: eu-west-3
environment: production
review_mode: false
secrets: inherit
2 changes: 1 addition & 1 deletion base
Submodule base updated from 4cb6bd to 0608f6
1 change: 1 addition & 0 deletions cooppilot/apps/cooppilot-back/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=postgresql://postgres:local@back-end-db:5432/cooppilot?schema=public
4 changes: 4 additions & 0 deletions cooppilot/apps/cooppilot-back/.env.container.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
APP_PORT = 3000
DATABASE_URL = "postgresql://postgres:local@back-end-db:5432/cooppilot?schema=public"
ADMIN_BACKEND_ENDPOINT = "http://back-end:3000"
ORGANIZATION_ID = "solution-plus"
4 changes: 4 additions & 0 deletions cooppilot/apps/cooppilot-back/.env.local.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
APP_PORT = 3002
DATABASE_URL = "postgresql://postgres:local@localhost:5433/cooppilot?schema=public"
ADMIN_BACKEND_ENDPOINT = "http://localhost:3001"
ORGANIZATION_ID = "solution-plus"
26 changes: 26 additions & 0 deletions cooppilot/apps/cooppilot-back/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
},
};
4 changes: 4 additions & 0 deletions cooppilot/apps/cooppilot-back/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
13 changes: 13 additions & 0 deletions cooppilot/apps/cooppilot-back/DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Back CoopPilot

# Docker Build/Push

from `./apps/cooppilot-back`:

```
aws ecr get-login-password --region eu-west-3 | docker login --username AWS --password-stdin 590183784519.dkr.ecr.eu-west-3.amazonaws.com
docker build -f Dockerfile -t 590183784519.dkr.ecr.eu-west-3.amazonaws.com/cooppilot-back_cooppilot:latest ./..
docker push 590183784519.dkr.ecr.eu-west-3.amazonaws.com/cooppilot-back_cooppilot:latest
```

# Kill task on ECS to trigger a new task instance
47 changes: 47 additions & 0 deletions cooppilot/apps/cooppilot-back/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM node:20-alpine as builder

ENV NODE_ENV build

RUN corepack enable pnpm

WORKDIR /app

COPY base/apps/common/.npmrc* base/apps/common/package.json base/apps/common/pnpm-lock.yaml ./base/apps/common/
# COPY cooppilot/apps/common/.npmrc* cooppilot/apps/common/package.json cooppilot/apps/common/pnpm-lock.yaml ./cooppilot/apps/common/
COPY cooppilot/apps/cooppilot-back/.npmrc* cooppilot/apps/cooppilot-back/package.json cooppilot/apps/cooppilot-back/pnpm-lock.yaml ./cooppilot/apps/cooppilot-back/

RUN cd base/apps/common && pnpm fetch
# RUN cd cooppilot/apps/common && pnpm fetch
RUN cd cooppilot/apps/cooppilot-back && pnpm fetch

RUN cd base/apps/common && pnpm install -r --prefer-offline
# RUN cd cooppilot/apps/common && pnpm install -r --prefer-offline
RUN cd cooppilot/apps/cooppilot-back && pnpm install -r --prefer-offline

COPY base/apps/common ./base/apps/common/
# COPY cooppilot/apps/common ./cooppilot/apps/common/
COPY cooppilot/apps/cooppilot-back ./cooppilot/apps/cooppilot-back/
RUN cd cooppilot/apps/cooppilot-back && pnpm dlx prisma@latest generate
RUN cd cooppilot/apps/cooppilot-back && pnpm run build

# ---

FROM node:20-alpine

ENV NODE_ENV production

WORKDIR /app

COPY --from=builder --chown=node:node /app/base/apps/common/package*.json ./base/apps/common/
COPY --from=builder --chown=node:node /app/base/apps/common/node_modules/ ./base/apps/common/node_modules/
# COPY --from=builder --chown=node:node /app/cooppilot/apps/common/package*.json ./cooppilot/apps/common/
# COPY --from=builder --chown=node:node /app/cooppilot/apps/common/node_modules/ ./cooppilot/apps/common/node_modules/
COPY --from=builder --chown=node:node /app/cooppilot/apps/cooppilot-back/package*.json ./cooppilot/apps/cooppilot-back/
COPY --from=builder --chown=node:node /app/cooppilot/apps/cooppilot-back/node_modules/ ./cooppilot/apps/cooppilot-back/node_modules/
COPY --from=builder /app/cooppilot/apps/cooppilot-back/dist/ ./
COPY cooppilot/apps/cooppilot-back/prisma ./cooppilot/apps/cooppilot-back/prisma/
COPY cooppilot/apps/cooppilot-back/startup.sh ./cooppilot/apps/cooppilot-back/

RUN chmod +x ./cooppilot/apps/cooppilot-back/startup.sh

CMD ["sh", "./cooppilot/apps/cooppilot-back/startup.sh"]
73 changes: 73 additions & 0 deletions cooppilot/apps/cooppilot-back/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Installation

```bash
$ npm install
```

## Running the app

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

## Test

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov
```

## Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
9 changes: 9 additions & 0 deletions cooppilot/apps/cooppilot-back/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"entryFile": "cooppilot/apps/cooppilot-back/src/main",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading

0 comments on commit 7968125

Please sign in to comment.