Skip to content

Commit

Permalink
Merge pull request #6 from Prorupak/development
Browse files Browse the repository at this point in the history
Automate Integration, Enhance Type Safety, and Optimize Deployment
  • Loading branch information
Prorupak authored Aug 28, 2024
2 parents 298f958 + e776a2b commit 7fce228
Show file tree
Hide file tree
Showing 26 changed files with 2,285 additions and 120 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.pnpm-store
docker-compose.yml
*.env
dist
out
coverage
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy

on:
push:
branches:
- master

jobs:
deploy_to_dev:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Install dependencies
run: |
npm install -g pnpm
pnpm init-project
- name: Lint
run: pnpm run lint
- name: Build
run: pnpm build

# SSH Deployment Steps
- name: Set up SSH Agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Execute Remote Commands
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << EOF
cd rupak/plugin-sample
git fetch --all
git checkout master
git pull origin master
git reset --hard origin/master
docker compose up --build
EOF
26 changes: 26 additions & 0 deletions .github/workflows/format_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check formatting and linting

on:
pull_request:
types:
- opened
- reopened
- edited
branches:
- development

jobs:
lint_and_format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js 18
uses: actions/setup-node@v2
with:
node-version: 18.x
- run: npm install -g pnpm
- run: pnpm i
- run: pnpm run lint
- run: pnpm build

30 changes: 30 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3"

services:
server:
container_name: server
build:
context: .
dockerfile: ./server/Dockerfile
restart: always
ports:
- 6000:6000
networks:
- app_network

nginx:
image: nginx:latest
container_name: nginx
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "80:80"
depends_on:
- server
networks:
- app_network

networks:
app_network:
name: app_network
external: true
25 changes: 25 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { cpus } = require("node:os");
const { config: dotConfig } = require("dotenv");

dotConfig({ path: ".env" });

const cpuLen = cpus().length;

module.exports = {
apps: [
{
name: "text-search-api",
script: "./dist/index.js",
autorestart: true,
exec_mode: "cluster",
watch: false,
instances: cpuLen,
max_memory_restart: "1G",
args: "",
env: {
NODE_ENV: process.env.NODE_ENV,
PORT: process.env.PORT,
},
},
],
};
12 changes: 12 additions & 0 deletions nignx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 80;
server_name plugin.sapkotarupak.com.np;

location / {
proxy_pass http://server:6000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
"scripts": {
"start-plugin": "cd plugin && pnpm watch",
"start-server": "cd server && pnpm dev",
"start-server-prod": "cd server && pnpm prod",
"build-plugin": "cd plugin && pnpm build",
"build-server": "cd server && pnpm build",
"lint-plugin": "cd plugin && pnpm lint",
"lint-server": "cd server && pnpm lint",
"start": "concurrently \"pnpm start-server\" \"pnpm start-plugin\"",
"lint": "concurrently \"pnpm lint-server\" \"pnpm lint-plugin\"",
"build": "concurrently \"pnpm build-server\" \"pnpm build-plugin\"",
"init-project": "pnpm i && concurrently \"cd plugin && pnpm install\" \"cd server && pnpm install\""
},
"keywords": [],
"author": "Rupak Sapkota <sapkotarupak5570@gmail.com>",
"license": "MIT",
"devDependencies": {
"concurrently": "^8.2.2"
},
"dependencies": {
"dotenv": "^16.4.5"
}
}
13 changes: 13 additions & 0 deletions plugin/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";


export default [
{files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"]},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
];
10 changes: 9 additions & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@eslint/js": "^9.9.1",
"@types/node": "^22.5.1",
"@types/react": "^16.8.2",
"@types/react-dom": "^16.8.0",
"css-loader": "^3.2.0",
"eslint": "^9.9.1",
"eslint-plugin-react": "^7.35.0",
"figma-plugin-types": "^0.1.3",
"globals": "^15.9.0",
"html-webpack-inline-source-plugin": "^0.0.10",
"html-webpack-plugin": "^3.2.0",
"prettier": "^1.18.2",
"style-loader": "^1.0.0",
"typescript": "^5.5.4",
"typescript-eslint": "^8.3.0",
"webpack-cli": "^3.3.7"
},
"scripts": {
"build": "webpack",
"watch": "webpack -w"
"watch": "webpack -w",
"lint": "eslint .",
"lint:fix": "pnpm run lint --fix",
"lint:format": "prettier --write \"src/**/*.{ts,tsx}\""
},
"dependencies": {
"react": "^16.8.6",
Expand Down
Loading

0 comments on commit 7fce228

Please sign in to comment.