fix prod build

This commit is contained in:
SrGooglo 2023-05-18 12:51:43 +00:00
parent 1b7a1f9cc6
commit b58a065b34
7 changed files with 52 additions and 19 deletions

View File

@ -1,8 +1,14 @@
{
"name": "comty.js",
"version": "0.1.0",
"version": "0.1.1",
"main": "./dist/index.js",
"author": "RageStudio <support@ragestudio.net>",
"scripts": {
"build": "corenode-cli build"
},
"files": [
"dist"
],
"license": "MIT",
"dependencies": {
"@foxify/events": "^2.1.0",
@ -11,5 +17,8 @@
"jsonwebtoken": "^9.0.0",
"jwt-decode": "^3.1.2",
"linebridge": "^0.15.12"
},
"devDependencies": {
"corenode": "^0.28.26"
}
}

View File

@ -7,16 +7,21 @@ RUN apt install --no-install-recommends curl python yarn build-essential -y
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
# Copy comty.js to node_modules
WORKDIR /home/node/app
USER node
EXPOSE 3010
EXPOSE 3040
COPY package.json ./
COPY --chown=node:node . .
RUN chmod -R 777 /home/node/app
RUN yarn install
RUN export NODE_ENV=production
RUN yarn global add cross-env
RUN yarn install --production
RUN yarn build
CMD ["node", "/home/node/app/dist/index.js"]
CMD ["yarn", "run", "run:prod"]

View File

@ -4,7 +4,8 @@
"main": "dist/index.js",
"scripts": {
"build": "corenode-cli build",
"dev": "cross-env NODE_ENV=development nodemon --ignore dist/ --exec corenode-node ./src/index.js"
"dev": "cross-env NODE_ENV=development nodemon --ignore dist/ --exec corenode-node ./src/index.js",
"run:prod": "cross-env NODE_ENV=production node ./dist/index.js"
},
"license": "MIT",
"dependencies": {
@ -15,6 +16,7 @@
"axios": "^1.2.5",
"bcrypt": "^5.1.0",
"busboy": "^1.6.0",
"comty.js": "^0.1.1",
"connect-mongo": "^4.6.0",
"content-range": "^2.0.2",
"corenode": "0.28.26",

View File

@ -1,12 +1,19 @@
require("dotenv").config()
global.isProduction = process.env.NODE_ENV === "production"
import { webcrypto as crypto } from "crypto"
import path from "path"
import { registerBaseAliases } from "linebridge/dist/server"
registerBaseAliases(undefined, {
const customAliases = {
"@services": path.resolve(__dirname, "services"),
"comty.js": path.resolve(__dirname, "../../comty.js/src"),
})
}
if (!global.isProduction) {
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
}
registerBaseAliases(undefined, customAliases)
// patches
const { Buffer } = require("buffer")
@ -42,8 +49,6 @@ global.toBoolean = (value) => {
return false
}
global.isProduction = process.env.NODE_ENV === "production"
import API from "./api"
async function main() {

View File

@ -1,9 +1,9 @@
FROM node:16-bullseye
FROM node:16-bullseye-slim
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt update
RUN apt install --no-install-recommends curl python yarn -y
RUN apt install --no-install-recommends curl python yarn build-essential -y
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
@ -16,8 +16,12 @@ COPY package.json ./
COPY --chown=node:node . .
RUN chmod -R 777 /home/node/app
RUN yarn install
RUN export NODE_ENV=production
RUN yarn global add cross-env
RUN yarn install --production
RUN yarn build
RUN npm rebuild @tensorflow/tfjs-node --build-from-source
CMD ["node", "/home/node/app/dist/index.js"]
CMD ["yarn", "run", "run:prod"]

View File

@ -4,7 +4,8 @@
"main": "dist/index.js",
"scripts": {
"build": "corenode-cli build",
"dev": "cross-env NODE_ENV=development nodemon --ignore dist/ --exec corenode-node ./src/index.js"
"dev": "cross-env NODE_ENV=development nodemon --ignore dist/ --exec corenode-node ./src/index.js",
"run:prod": "cross-env NODE_ENV=production node ./dist/index.js"
},
"license": "MIT",
"dependencies": {
@ -35,6 +36,7 @@
"mongoose": "^6.9.0",
"music-metadata": "^8.1.3",
"normalize-url": "^8.0.0",
"comty.js": "^0.1.1",
"nsfwjs": "2.4.2",
"p-map": "^6.0.0",
"p-queue": "^7.3.4",

View File

@ -1,11 +1,19 @@
require("dotenv").config()
global.isProduction = process.env.NODE_ENV === "production"
import { webcrypto as crypto } from "crypto"
import path from "path"
import { registerBaseAliases } from "linebridge/dist/server"
registerBaseAliases(undefined, {
const customAliases = {
"@services": path.resolve(__dirname, "services"),
})
}
if (!global.isProduction) {
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
}
registerBaseAliases(undefined, customAliases)
// patches
const { Buffer } = require("buffer")
@ -41,8 +49,6 @@ global.toBoolean = (value) => {
return false
}
global.isProduction = process.env.NODE_ENV === "production"
import API from "./api"
async function main() {