This commit is contained in:
2025-01-07 06:22:59 +00:00
parent c485423911
commit ce7253b4b1
15 changed files with 234 additions and 10 deletions

View File

@@ -0,0 +1,7 @@
node_modules
logs
*.log
*.md
Dockerfile
docker-compose.yml

19
backend-server/Dockerfile Normal file
View 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"]

View 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"]

View File

@@ -0,0 +1,11 @@
version: '3.8'
services:
link-manage-backend:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
deploy:
replicas: 3

View 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"

View File

@@ -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",
"dotenv": "^16.4.5",

View 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"
}
}

View File

@@ -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"
import dotenv from "dotenv";
@@ -99,7 +99,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)=>{
@@ -184,8 +184,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({
@@ -218,4 +219,4 @@ app.get("/api/secrets",async(req,res)=>{
const PORT = 3000;
app.listen(PORT,()=>{
console.log(`Server started on port ${PORT}`)
})
})

View File

@@ -0,0 +1,7 @@
FROM node
WORKDIR /app
COPY ./package.json .

View 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"
}
}