This commit is contained in:
3
backend/.env.example
Normal file
3
backend/.env.example
Normal file
@@ -0,0 +1,3 @@
|
||||
PORT=5000
|
||||
DB_URI=mongodb://localhost:27017/
|
||||
NODE_ENV=development
|
||||
16
backend/.gitignore
vendored
Normal file
16
backend/.gitignore
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Node dependencies
|
||||
node_modules
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.fleet
|
||||
.idea
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
23
backend/Dockerfile
Normal file
23
backend/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
# Use official Node.js runtime
|
||||
FROM node:20-alpine
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy package files first (better caching)
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy application source
|
||||
COPY . .
|
||||
|
||||
# Expose the app port
|
||||
# EXPOSE 3000
|
||||
|
||||
# Environment variable
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Start the application
|
||||
CMD ["node", "src/index.js"]
|
||||
1368
backend/package-lock.json
generated
Normal file
1368
backend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
backend/package.json
Normal file
18
backend/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "backend",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"license": "ISC",
|
||||
"author": "",
|
||||
"type": "commonjs",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"dev": "nodemon src/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^17.3.1",
|
||||
"express": "^5.2.1",
|
||||
"mongoose": "^9.3.0",
|
||||
"nodemon": "^3.1.14"
|
||||
}
|
||||
}
|
||||
14
backend/src/db.js
Normal file
14
backend/src/db.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
const connectDB = async () => {
|
||||
try {
|
||||
await mongoose.connect(process.env.DB_URI);
|
||||
|
||||
console.log("MongoDB connected");
|
||||
} catch (error) {
|
||||
console.error("MongoDB connection error:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = connectDB;
|
||||
16
backend/src/index.js
Normal file
16
backend/src/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const express = require("express");
|
||||
|
||||
require('dotenv').config();
|
||||
const app = express();
|
||||
const connectDB = require("./db");
|
||||
|
||||
// connect database
|
||||
connectDB();
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.send("Hello from Proxmox container!");
|
||||
});
|
||||
|
||||
app.listen(5000, () => {
|
||||
console.log("Server running on port 5000");
|
||||
});
|
||||
Reference in New Issue
Block a user