New Branch
This commit is contained in:
21
Dockerfile
Normal file
21
Dockerfile
Normal 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"]
|
||||||
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",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "cd src && nodemon index.ts",
|
"start": "cd src && ts-node index.ts",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"serve": "node dist/index.js"
|
"serve": "node dist/index.js"
|
||||||
},
|
},
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bcrypt": "^5.1.1",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
"express": "^4.21.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 express from "express";
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {vols} from "../../src/app/backup"
|
//import {vols} from "../../src/app/backup"
|
||||||
import {all_tools} from "../../src/app/urls"
|
//import {all_tools} from "../../src/app/urls"
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
import bcrypt from "bcrypt"
|
import bcrypt from "bcrypt"
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ app.get("/seed-backup", async (req,res)=>{
|
|||||||
// if (backupCount > 0) {
|
// if (backupCount > 0) {
|
||||||
// res.send("Seed already done")
|
// res.send("Seed already done")
|
||||||
// }
|
// }
|
||||||
BackupModel.create(vols)
|
// BackupModel.create(vols)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get("/", (req,res)=>{
|
app.get("/", (req,res)=>{
|
||||||
@@ -183,8 +183,9 @@ function decryptPassword(encryptedPassword: string, iv: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.get("/api/seed-creds",async(req,res)=>{
|
app.get("/api/seed-creds",async(req,res)=>{
|
||||||
const all_creds: ICreds[] = all_tools;
|
// const all_creds: ICreds[] = all_tools;
|
||||||
for (const cred of all_creds) {
|
const all_creds: ICreds[] = [];
|
||||||
|
for (const cred of all_creds) {
|
||||||
const { iv, encryptedPassword} = encryptPassword(cred.password)
|
const { iv, encryptedPassword} = encryptPassword(cred.password)
|
||||||
|
|
||||||
const newCred =new CredsModel({
|
const newCred =new CredsModel({
|
||||||
@@ -217,4 +218,4 @@ app.get("/api/secrets",async(req,res)=>{
|
|||||||
const PORT = 3000;
|
const PORT = 3000;
|
||||||
app.listen(PORT,()=>{
|
app.listen(PORT,()=>{
|
||||||
console.log(`Server started on port ${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"
|
||||||
|
}
|
||||||
|
}
|
||||||
14
default.conf
Normal file
14
default.conf
Normal 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
6
docker-compose.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
version: '3.9'
|
||||||
|
services:
|
||||||
|
navigator:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "12180:80"
|
||||||
20
nginx.conf
Normal file
20
nginx.conf
Normal 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;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
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 BACKUP_GET_URL = `${MAIN_URL}/backup`;
|
||||||
export const UPDATE_GET_URL = `${MAIN_URL}/update`;
|
export const UPDATE_GET_URL = `${MAIN_URL}/update`;
|
||||||
export const UPDATE_ADD_URL = `${UPDATE_GET_URL}/add`;
|
export const UPDATE_ADD_URL = `${UPDATE_GET_URL}/add`;
|
||||||
export const UPDATE_COMPLETE_URL = `${UPDATE_GET_URL}/complete`;
|
export const UPDATE_COMPLETE_URL = `${UPDATE_GET_URL}/complete`;
|
||||||
export const UPDATE_DELETE_URL = `${UPDATE_GET_URL}/delete`;
|
export const UPDATE_DELETE_URL = `${UPDATE_GET_URL}/delete`;
|
||||||
export const SECRET_URL = `${MAIN_URL}/secrets`;
|
export const SECRET_URL = `${MAIN_URL}/secrets`;
|
||||||
|
|||||||
Reference in New Issue
Block a user