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

21
Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM ubuntu:plucky
RUN apt update && apt upgrade -y
RUN apt install git -y
RUN mkdir library && cd library
WORKDIR ~/library/
RUN git init
RUN git remote add origin https://github.com/dumsilor/library.git
RUN git pull origin master
RUN apt install npm
RUN npm i
CMD ["ng","serve"]

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,7 +184,8 @@ function decryptPassword(encryptedPassword: string, iv: string) {
}
app.get("/api/seed-creds",async(req,res)=>{
const all_creds: ICreds[] = all_tools;
// const all_creds: ICreds[] = all_tools;
const all_creds: ICreds[] = [];
for (const cred of all_creds) {
const { iv, encryptedPassword} = encryptPassword(cred.password)

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

14
default.conf Normal file
View File

@@ -0,0 +1,14 @@
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

6
docker-compose.yml Normal file
View File

@@ -0,0 +1,6 @@
version: '3.9'
services:
navigator:
build: .
ports:
- "12180:80"

20
nginx.conf Normal file
View File

@@ -0,0 +1,20 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}

View File

@@ -1,4 +1,4 @@
const MAIN_URL = "http://localhost:3000/api"
const MAIN_URL = "http://118.67.213.117:3000/api"
export const BACKUP_GET_URL = `${MAIN_URL}/backup`;
export const UPDATE_GET_URL = `${MAIN_URL}/update`;