Skip to content

Commit

Permalink
chore: refactor deployment setup and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Nov 20, 2023
1 parent 39675a5 commit 7151472
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 153 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test
on: push
jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20

- run: npm ci

- run: npm run lint
- run: npm run test
- run: npm run build
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ COPY package.json package-lock.json ./
ENV NODE_ENV=production
RUN npm install
COPY --from=builer /app/dist ./dist
CMD [ "npm", "start" ]
RUN npm install pm2 -g
CMD ["pm2-runtime", "dist/index.js"]
21 changes: 10 additions & 11 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>'],
moduleDirectories: [
'node_modules',
'<rootDir>',
],
moduleFileExtensions: ['js', 'ts', 'tsx', 'json'],
testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules|.next|cypress)[/\\\\]'],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$']
};
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>"],
moduleDirectories: ["node_modules", "<rootDir>"],
moduleFileExtensions: ["js", "ts", "tsx", "json"],
testPathIgnorePatterns: [
"<rootDir>[/\\\\](node_modules|.next|cypress)[/\\\\]",
],
transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$"],
};
131 changes: 0 additions & 131 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "web-backend",
"version": "1.0.0",
"private": true,
"description": "",
"main": "index.js",
"scripts": {
"dev": "NODE_ENV=development nodemon",
"build": "tsc",
"dev": "NODE_ENV=development nodemon",
"lint": "eslint . --ext .ts && prettier './**/*.{ts,js}' --check",
"start": "NODE_ENV=production node dist/index.js",
"lint": "eslint . --ext .ts",
"test": "NODE_ENV=test jest"
},
"keywords": [],
Expand All @@ -18,7 +19,6 @@
"@apollo/server": "^4.0.2",
"@types/express": "^4.17.13",
"@types/nodemailer": "^6.4.4",
"@types/supertest": "^2.0.11",
"body-parser": "^1.20.1",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
Expand All @@ -39,7 +39,6 @@
"jest": "^29.7.0",
"nodemon": "^3.0.1",
"prettier": "^3.1.0",
"supertest": "^6.1.6",
"ts-jest": "^29.1.1",
"ts-node": "^10.7.0",
"tsconfig-paths": "^4.2.0",
Expand Down
12 changes: 6 additions & 6 deletions scripts/docker_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ SCRIPT_PATH="$(
cd "$SCRIPT_PATH/.."

docker build \
-t web-backed \
-t web-backend \
.

docker stop web-backed || true
docker rm web-backed || true
docker stop web-backend || true
docker rm web-backend || true

docker run \
--name web-backed \
--name web-backend \
--restart always \
-v $(pwd)/.env:/app/.env \
-p 4100:4000 \
-p 4000:4000 \
-d \
web-backed
web-backend

docker system prune -fa

Expand Down

0 comments on commit 7151472

Please sign in to comment.