Füge Dockerfile hinzu und passe ExpressManager an, um den Frontend-Pfad aus Umgebungsvariablen zu laden
This commit is contained in:
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Use an official Node.js runtime as the base image
|
||||||
|
FROM node:18
|
||||||
|
|
||||||
|
# Set the working directory inside the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package.json and package-lock.json to install dependencies
|
||||||
|
COPY backend/package*.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Copy backend source files
|
||||||
|
COPY backend /app/backend
|
||||||
|
|
||||||
|
# Copy frontend files and serve them as static assets
|
||||||
|
COPY frontend /app/frontend
|
||||||
|
|
||||||
|
# Set environment variable to production
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Expose the port the app runs on
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Start the application
|
||||||
|
CMD ["node", "backend/src/server.js"]
|
||||||
@@ -5,6 +5,7 @@ const path = require("path");
|
|||||||
const DataBaseManager = require("../Database/DataBaseManager");
|
const DataBaseManager = require("../Database/DataBaseManager");
|
||||||
const AccountRoute = require("./Routes/AccountRoute");
|
const AccountRoute = require("./Routes/AccountRoute");
|
||||||
const DashboardRoute = require("./Routes/DashboardRoute");
|
const DashboardRoute = require("./Routes/DashboardRoute");
|
||||||
|
require("dotenv").config();
|
||||||
|
|
||||||
class ExpressManager{
|
class ExpressManager{
|
||||||
/**@param {DataBaseManager} dbManager*/
|
/**@param {DataBaseManager} dbManager*/
|
||||||
@@ -26,7 +27,7 @@ class ExpressManager{
|
|||||||
this.app.use(bp.urlencoded({extended: false}));
|
this.app.use(bp.urlencoded({extended: false}));
|
||||||
this.app.use(express.json());
|
this.app.use(express.json());
|
||||||
this.app.use(bp.json());
|
this.app.use(bp.json());
|
||||||
this.app.use(express.static(path.join(__dirname, "./../../../frontend")));
|
this.app.use(express.static(path.join(__dirname, process.env.FRONTEND_PATH || "./../../../frontend")));
|
||||||
|
|
||||||
// Routen wo man für Angemeldet sein muss
|
// Routen wo man für Angemeldet sein muss
|
||||||
this.authRoutes = [
|
this.authRoutes = [
|
||||||
|
|||||||
Reference in New Issue
Block a user