added web static service

This commit is contained in:
SrGooglo 2024-02-07 00:46:53 +01:00
parent 5761947915
commit 9acf0b4448
3 changed files with 37 additions and 0 deletions

20
node_api/Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM node:16-bullseye-slim
RUN apt update
RUN apt install build-essential -y
RUN apt install python3 -y
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
USER node
EXPOSE 3000
COPY --chown=node:node . .
RUN chmod -R 777 /home/node/app
RUN npm install -D --force
RUN npm run build
CMD ["node", "/home/node/app/api/index.js"]

View File

@ -1,6 +1,7 @@
require('dotenv').config()
const express = require("express")
const path = require("path")
const cors = require("cors")
const mlib = require("../../node_lib")
@ -32,6 +33,13 @@ async function main() {
res.json(phrases)
})
app.use(express.static(path.join(__dirname, "..", "web", "dist",)))
// serve static react build
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "..", "web", "dist", "index.html"))
})
app.listen(PORT)
console.log(`Listening on port ${PORT}`)

View File

@ -0,0 +1,9 @@
version: "3"
services:
web:
container_name: monstercanker-service
build: .
restart: unless-stopped
ports:
- "3000:3000"