mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Add production deployment
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
FROM node:24 AS frontend
|
||||
|
||||
WORKDIR /app
|
||||
COPY package.json .
|
||||
RUN npm install --ignore-scripts
|
||||
|
||||
COPY frontend frontend
|
||||
RUN npm run build
|
||||
|
||||
FROM node:24 AS server
|
||||
|
||||
WORKDIR /server
|
||||
COPY deployment/frontend/package.json .
|
||||
RUN npm install
|
||||
COPY deployment/frontend/ .
|
||||
|
||||
FROM node:24-slim
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=frontend /app/frontend/dist .
|
||||
|
||||
WORKDIR /server
|
||||
COPY --from=server /server .
|
||||
|
||||
ENV STATIC_FILE_PATH=/app
|
||||
ENTRYPOINT ["npm", "run", "start"]
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "frontend-server",
|
||||
"version": "1.0.0",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^5.1.0",
|
||||
"http-proxy-middleware": "^3.0.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// server.js
|
||||
const express = require('express');
|
||||
const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||
const path = require('path');
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3000;
|
||||
const backendHost = process.env.BACKEND_HOST || "http://localhost:8300";
|
||||
const file_path = process.env.STATIC_FILE_PATH || ".";
|
||||
|
||||
app.use('/api', createProxyMiddleware({
|
||||
target: backendHost,
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/api': '' },
|
||||
ws: true
|
||||
}));
|
||||
|
||||
app.use(express.static(path.resolve(file_path)));
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server launched на http://localhost:${port}`);
|
||||
});
|
||||
Reference in New Issue
Block a user