fix: docker container are starting
This commit is contained in:
+29
-5
@@ -1,12 +1,36 @@
|
||||
FROM node:20-alpine
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
COPY backend/package.json backend/
|
||||
COPY frontend/package.json frontend/
|
||||
COPY shared/package.json shared/
|
||||
|
||||
RUN npm ci
|
||||
|
||||
COPY shared/ shared/
|
||||
COPY backend/ backend/
|
||||
|
||||
RUN npm run build --workspace=shared
|
||||
RUN npm run build --workspace=backend
|
||||
|
||||
FROM node:22-alpine AS runner
|
||||
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /backend
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
COPY backend/package.json backend/
|
||||
COPY frontend/package.json frontend/
|
||||
COPY shared/package.json shared/
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
COPY . .
|
||||
COPY --from=builder /app/backend/dist backend/dist
|
||||
COPY --from=builder /app/backend/database.scheme.sql backend/
|
||||
COPY --from=builder /app/shared/dist shared/dist
|
||||
|
||||
EXPOSE 8004
|
||||
CMD ["npm", "start"]
|
||||
WORKDIR /app/backend
|
||||
CMD ["node", "dist/server.js"]
|
||||
Generated
-1096
File diff suppressed because it is too large
Load Diff
@@ -4,15 +4,14 @@
|
||||
"description": "",
|
||||
"main": "server.ts",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node dist/server.js",
|
||||
"dev": "tsx --watch server.ts",
|
||||
"build": "babel server.ts routes services --extensions .ts --out-dir dist --copy-files"
|
||||
"build": "tsc -b",
|
||||
"start": "node dist/server.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "module",
|
||||
"type": "commonjs",
|
||||
"dependencies": {
|
||||
"@stockhome/shared": "1.0.0",
|
||||
"cors": "^2.8.5",
|
||||
@@ -23,12 +22,9 @@
|
||||
"mysql2": "^3.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^8.0.1",
|
||||
"@babel/core": "^8.0.1",
|
||||
"@babel/preset-env": "^8.0.2",
|
||||
"@babel/preset-typescript": "^8.0.1",
|
||||
"@types/express": "^5.0.6",
|
||||
"@types/node": "^26.1.0",
|
||||
"typescript": "~6.0.2",
|
||||
"tsx": "^4.23.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
import express from "express";
|
||||
import dotenv from "dotenv";
|
||||
import {authenticate} from "../../services/tokenService.ts";
|
||||
import {authenticate} from "../../services/tokenService";
|
||||
import {
|
||||
allProducts,
|
||||
deleteProduct,
|
||||
newProduct,
|
||||
productDetails,
|
||||
setAmount,
|
||||
updateItem,
|
||||
} from "./database/products.database.ts";
|
||||
allProducts,
|
||||
deleteProduct,
|
||||
newProduct,
|
||||
productDetails,
|
||||
setAmount,
|
||||
updateItem,
|
||||
} from "./database/products.database";
|
||||
import {GENERAL_ERROR_CODE, PRODUCT_ERROR_CODE} from "@stockhome/shared";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import express from "express";
|
||||
import dotenv from "dotenv";
|
||||
import {authenticate} from "../../services/tokenService.js";
|
||||
import {allStorages, deleteStorage, newStorage, updateStorage,} from "./database/storage.database.ts";
|
||||
import {authenticate} from "../../services/tokenService";
|
||||
import {allStorages, deleteStorage, newStorage, updateStorage,} from "./database/storage.database";
|
||||
import {GENERAL_ERROR_CODE, STORAGE_ERROR_CODE} from "@stockhome/shared";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import express from "express";
|
||||
import dotenv from "dotenv";
|
||||
import {authenticate, generateToken} from "../../services/tokenService.ts";
|
||||
import {changePassword, findUser, getSettings, loginUser, updateSettings,} from "./database/users.database.ts";
|
||||
import {authenticate, generateToken} from "../../services/tokenService";
|
||||
import {changePassword, findUser, getSettings, loginUser, updateSettings,} from "./database/users.database";
|
||||
import {GENERAL_ERROR_CODE, USER_ERROR_CODE} from "@stockhome/shared";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
+5
-4
@@ -5,9 +5,10 @@ import dotenv from "dotenv";
|
||||
import mysql, {type ResultSetHeader, type RowDataPacket} from "mysql2";
|
||||
import {readFile} from "fs/promises";
|
||||
// frontend routes
|
||||
import userRouter from "./routes/app/users.route.ts";
|
||||
import productRouter from "./routes/app/products.route.ts";
|
||||
import storageRouter from "./routes/app/storage.route.ts";
|
||||
import userRouter from "./routes/app/users.route";
|
||||
import productRouter from "./routes/app/products.route";
|
||||
import storageRouter from "./routes/app/storage.route";
|
||||
import path from "node:path";
|
||||
|
||||
dotenv.config();
|
||||
const app = express();
|
||||
@@ -55,7 +56,7 @@ const runStartup = async (port: number) => {
|
||||
}
|
||||
|
||||
if (firstStartupValue !== "false") {
|
||||
const schemaPath = new URL("./database.scheme.sql", import.meta.url);
|
||||
const schemaPath = path.join(__dirname, "database.scheme.sql");
|
||||
const schemaSql = await readFile(schemaPath, "utf8");
|
||||
const statements = schemaSql
|
||||
.split(";")
|
||||
|
||||
+25
-34
@@ -1,45 +1,36 @@
|
||||
{
|
||||
// Visit https://aka.ms/tsconfig to read more about this file
|
||||
"compilerOptions": {
|
||||
// File Layout
|
||||
// "rootDir": "./src",
|
||||
"composite": true,
|
||||
"rootDir": ".",
|
||||
"outDir": "./dist",
|
||||
// Environment Settings
|
||||
// See also https://aka.ms/tsconfig/module
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"module": "CommonJS",
|
||||
"target": "ES2022",
|
||||
"moduleResolution": "Node",
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "bundler",
|
||||
// For nodejs:
|
||||
// "lib": ["esnext"],
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"ignoreDeprecations": "6.0",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
// and npm install -D @types/node
|
||||
|
||||
// Other Outputs
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
// Stricter Typechecking Options
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
// Style Options
|
||||
// "noImplicitReturns": true,
|
||||
// "noImplicitOverride": true,
|
||||
// "noUnusedLocals": true,
|
||||
// "noUnusedParameters": true,
|
||||
// "noFallthroughCasesInSwitch": true,
|
||||
// "noPropertyAccessFromIndexSignature": true,
|
||||
|
||||
// Recommended Options
|
||||
"strict": true,
|
||||
"jsx": "react-jsx",
|
||||
"verbatimModuleSyntax": true,
|
||||
"isolatedModules": true,
|
||||
"noUncheckedSideEffectImports": true,
|
||||
"moduleDetection": "force",
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"./**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"**/vite.config.ts",
|
||||
"**/vite.config.*",
|
||||
"**/*.config.ts",
|
||||
"**/*.config.*"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../shared"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user