added static deployment

This commit is contained in:
srgooglo 2022-05-31 02:47:36 +02:00
parent 1eb76f1a3e
commit f76f869243
3 changed files with 41 additions and 0 deletions

18
packages/app/Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM node:16-alpine
RUN apk add git
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
USER node
EXPOSE 9000
COPY package.json ./
COPY --chown=node:node . .
RUN chmod -R 777 /home/node/app
RUN npm install
RUN npm run build:dist
CMD ["node", "/home/node/app/server.js"]

View File

@ -0,0 +1,8 @@
version: "3"
services:
app:
build: "."
restart: unless-stopped
ports:
- "9000:9000"

15
packages/app/server.js Normal file
View File

@ -0,0 +1,15 @@
const express = require("express")
const path = require("path")
const app = express()
const portFromArgs = process.argv[2]
let portListen = portFromArgs ? portFromArgs : 9000
app.use(express.static(path.join(__dirname, "dist")))
app.get("/", function (req, res) {
res.sendFile(path.join(__dirname, "dist", "index.html"))
})
app.listen(portListen)
console.log(`🌐 Listening app in port [${portListen}]`)