New Branch
This commit is contained in:
7
backend-server/.dockerignore
Normal file
7
backend-server/.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
||||
node_modules
|
||||
logs
|
||||
*.log
|
||||
*.md
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
|
||||
19
backend-server/Dockerfile
Normal file
19
backend-server/Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN chown -R node:node /app
|
||||
|
||||
USER node
|
||||
|
||||
RUN npm i --production
|
||||
|
||||
RUN npm install --save-dev @types/cors
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm","start"]
|
||||
44
backend-server/Dockerfile.bkp2
Normal file
44
backend-server/Dockerfile.bkp2
Normal file
@@ -0,0 +1,44 @@
|
||||
# Use the official Ubuntu base image
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Set environment variables to avoid prompts during package installations
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Update the package list and install necessary dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
gnupg2 \
|
||||
build-essential \
|
||||
unzip
|
||||
|
||||
RUN curl -fsSL https://fnm.vercel.app/install | bash \
|
||||
&& export PATH="/root/.fnm:$PATH" \
|
||||
&& eval "$(fnm env)" \
|
||||
&& fnm install 22 \
|
||||
&& fnm use 22 \
|
||||
&& fnm alias default 22
|
||||
|
||||
# Install nodemon globally
|
||||
RUN export PATH="/root/.fnm:$PATH" \
|
||||
&& eval "$(fnm env)" \
|
||||
&& npm install -g nodemon
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /home/node/app
|
||||
|
||||
# Copy the package.json and package-lock.json files to the container
|
||||
COPY package*.json ./
|
||||
|
||||
# Install the application dependencies
|
||||
RUN export PATH="/root/.fnm:$PATH" \
|
||||
&& eval "$(fnm env)" \
|
||||
&& npm install --legacy-peer-deps
|
||||
|
||||
# Copy the rest of the application code to the container
|
||||
COPY . .
|
||||
|
||||
# Expose the application port
|
||||
EXPOSE 3000
|
||||
|
||||
# Default command (can be overridden by docker-compose)
|
||||
CMD ["npm", "start"]
|
||||
11
backend-server/docker-compose.yml
Normal file
11
backend-server/docker-compose.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
link-manage-backend:
|
||||
build: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
deploy:
|
||||
replicas: 3
|
||||
17
backend-server/docker-compose.yml.bkp2
Normal file
17
backend-server/docker-compose.yml.bkp2
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
services:
|
||||
link-manage-backend:
|
||||
image: "node:23"
|
||||
user: "node"
|
||||
working_dir: /home/node/app
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
volumes:
|
||||
- ./:/home/node/app
|
||||
expose:
|
||||
- "3000"
|
||||
ports:
|
||||
- "3000:3000"
|
||||
command:
|
||||
- "npm i"
|
||||
- "npm start"
|
||||
@@ -4,7 +4,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "cd src && nodemon index.ts",
|
||||
"start": "cd src && ts-node index.ts",
|
||||
"build": "tsc",
|
||||
"serve": "node dist/index.js"
|
||||
},
|
||||
@@ -13,7 +13,6 @@
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.1.1",
|
||||
"cors": "^2.8.5",
|
||||
"crypto": "^1.0.1",
|
||||
"express": "^4.21.1",
|
||||
|
||||
29
backend-server/package.json.bkp
Normal file
29
backend-server/package.json.bkp
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "backend-server",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "cd src && nodemon index.ts",
|
||||
"build": "tsc",
|
||||
"serve": "node dist/index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.1.1",
|
||||
"cors": "^2.8.5",
|
||||
"crypto": "^1.0.1",
|
||||
"express": "^4.21.1",
|
||||
"mongoose": "^8.8.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/node": "^22.9.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import express from "express";
|
||||
import cors from 'cors';
|
||||
import mongoose from 'mongoose';
|
||||
import {vols} from "../../src/app/backup"
|
||||
import {all_tools} from "../../src/app/urls"
|
||||
//import {vols} from "../../src/app/backup"
|
||||
//import {all_tools} from "../../src/app/urls"
|
||||
import crypto from "crypto";
|
||||
import bcrypt from "bcrypt"
|
||||
|
||||
@@ -98,7 +98,7 @@ app.get("/seed-backup", async (req,res)=>{
|
||||
// if (backupCount > 0) {
|
||||
// res.send("Seed already done")
|
||||
// }
|
||||
BackupModel.create(vols)
|
||||
// BackupModel.create(vols)
|
||||
})
|
||||
|
||||
app.get("/", (req,res)=>{
|
||||
@@ -183,8 +183,9 @@ function decryptPassword(encryptedPassword: string, iv: string) {
|
||||
}
|
||||
|
||||
app.get("/api/seed-creds",async(req,res)=>{
|
||||
const all_creds: ICreds[] = all_tools;
|
||||
for (const cred of all_creds) {
|
||||
// const all_creds: ICreds[] = all_tools;
|
||||
const all_creds: ICreds[] = [];
|
||||
for (const cred of all_creds) {
|
||||
const { iv, encryptedPassword} = encryptPassword(cred.password)
|
||||
|
||||
const newCred =new CredsModel({
|
||||
@@ -217,4 +218,4 @@ app.get("/api/secrets",async(req,res)=>{
|
||||
const PORT = 3000;
|
||||
app.listen(PORT,()=>{
|
||||
console.log(`Server started on port ${PORT}`)
|
||||
})
|
||||
})
|
||||
|
||||
7
backend-server/test/Dockerfile
Normal file
7
backend-server/test/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM node
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./package.json .
|
||||
|
||||
|
||||
29
backend-server/test/package.json
Normal file
29
backend-server/test/package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "backend-server",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "cd src && nodemon index.ts",
|
||||
"build": "tsc",
|
||||
"serve": "node dist/index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.1.1",
|
||||
"cors": "^2.8.5",
|
||||
"crypto": "^1.0.1",
|
||||
"express": "^4.21.1",
|
||||
"mongoose": "^8.8.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/node": "^22.9.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user