Dockerize gather

This commit is contained in:
2024-02-04 19:09:33 +03:00
parent db9180721a
commit 9a50b2c6cf
11 changed files with 2626 additions and 3049 deletions

View File

@@ -1,65 +0,0 @@
kind: pipeline
type: ssh
name: install dependencies
server:
host: warframe.center
user: webmaster
ssh_key:
from_secret: ssh_private_key
clone:
disable: true
steps:
- name: fetch remote
commands:
- cd /home/webmaster/warframe-center && git fetch --all && git reset --hard origin/monorepo
- name: install dependencies
commands:
- export PATH=$PATH:/home/webmaster/.nvm/versions/node/v16.14.2/bin
- cd /home/webmaster/warframe-center && npm install
trigger:
branch:
- monorepo
---
kind: pipeline
type: docker
name: build
clone:
disable: true
steps:
- name: bulid frontend
image: node:16
environment:
SSH_PRIVATE_KEY:
from_secret: SSH_PRIVATE_KEY
MONGODB_URI:
from_secret: MONGODB_URI
commands:
- git clone -b monorepo https://git.radner.ru/anatolykopyl/warframe-center.git
- cd warframe-center
- npm install
- npm run build -w app
- mkdir ~/.ssh
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 400 ~/.ssh/id_rsa
- scp -o StrictHostKeyChecking=no -r ./app/.next webmaster@warframe.center:~/warframe-center/app
- |
ssh -o StrictHostKeyChecking=no webmaster@warframe.center '
[ -s ~/.nvm/nvm.sh ] && source ~/.nvm/nvm.sh &&
nvm use default &&
pm2 restart warframe-center-app-3000
'
depends_on:
- install dependencies
trigger:
branch:
- monorepo

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@ node_modules
.DS_Store .DS_Store
.vscode .vscode
.env .env
.idea
.yarn

View File

@@ -1,7 +0,0 @@
module.exports = {
apps: [{
name: 'warframe-center-app-3000',
script: 'npm run start',
watch: false
}]
}

9
gather/Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM node:20-alpine
LABEL authors="anatolykopyl"
WORKDIR /usr/node/app
COPY package*.json ./
RUN npm ci
COPY . .

View File

@@ -0,0 +1,9 @@
version: '3'
services:
warframe-center-gather:
image: git.radner.ru/anatolykopyl/warframe-center-gather:latest
container_name: warframe-center-gather
working_dir: /usr/node/app
command: >
sh -c "node src/index.js"

View File

@@ -1,9 +0,0 @@
module.exports = {
apps: [{
name: 'warframe-center-gather',
script: './src/index.js',
watch: true,
ignore_watch: ['node_modules', 'public'],
restart_delay: 1 * 60 * 1000
}]
}

View File

@@ -15,7 +15,6 @@
"shared-stuff": "file:../shared-stuff" "shared-stuff": "file:../shared-stuff"
}, },
"devDependencies": { "devDependencies": {
"eslint-config-standard": "^16.0.3", "eslint-config-standard": "^16.0.3"
"pm2": "^5.2.0"
} }
} }

View File

@@ -7,8 +7,10 @@ async function initDB () {
await mongoose.connect(process.env.MONGODB_URI) await mongoose.connect(process.env.MONGODB_URI)
} }
(async () => { const main = async (firstLaunch) => {
if (firstLaunch) {
await initDB() await initDB()
}
for (const item of items) { for (const item of items) {
process.stdout.write(`Looking at ${item.name}: `) process.stdout.write(`Looking at ${item.name}: `)
@@ -36,5 +38,13 @@ async function initDB () {
console.log('✅') console.log('✅')
} }
await mongoose.disconnect() await main()
})() }
main(true)
process.on('SIGINT', () => {
mongoose.disconnect().then(() => {
process.exit()
})
})

5523
package-lock.json generated

File diff suppressed because it is too large Load Diff

11
shared-stuff/dist/index.js vendored Normal file
View File

@@ -0,0 +1,11 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.models = void 0;
const ScanResult_1 = __importDefault(require("./models/ScanResult"));
const models = {
ScanResult: ScanResult_1.default
};
exports.models = models;

17
shared-stuff/dist/models/ScanResult.js vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = __importDefault(require("mongoose"));
const scanResultSchema = new mongoose_1.default.Schema({
name: String,
fullName: String,
url: String,
partsPrice: Number,
setPrice: Number,
difference: Number
}, {
timestamps: true
});
exports.default = mongoose_1.default.models.ScanResult || mongoose_1.default.model('ScanResult', scanResultSchema);