fix: docker container are starting
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
.LSOverride
|
.LSOverride
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
|
tsconfig.tsbuildinfo
|
||||||
|
|
||||||
# Icon must end with two \r
|
# Icon must end with two \r
|
||||||
|
|
||||||
|
|||||||
+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
|
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
|
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
|
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": "",
|
"description": "",
|
||||||
"main": "server.ts",
|
"main": "server.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
|
||||||
"start": "node dist/server.js",
|
|
||||||
"dev": "tsx --watch server.ts",
|
"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": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"type": "module",
|
"type": "commonjs",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@stockhome/shared": "1.0.0",
|
"@stockhome/shared": "1.0.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
@@ -23,12 +22,9 @@
|
|||||||
"mysql2": "^3.16.0"
|
"mysql2": "^3.16.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"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/express": "^5.0.6",
|
||||||
"@types/node": "^26.1.0",
|
"@types/node": "^26.1.0",
|
||||||
|
"typescript": "~6.0.2",
|
||||||
"tsx": "^4.23.0"
|
"tsx": "^4.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
import {authenticate} from "../../services/tokenService.ts";
|
import {authenticate} from "../../services/tokenService";
|
||||||
import {
|
import {
|
||||||
allProducts,
|
allProducts,
|
||||||
deleteProduct,
|
deleteProduct,
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
productDetails,
|
productDetails,
|
||||||
setAmount,
|
setAmount,
|
||||||
updateItem,
|
updateItem,
|
||||||
} from "./database/products.database.ts";
|
} from "./database/products.database";
|
||||||
import {GENERAL_ERROR_CODE, PRODUCT_ERROR_CODE} from "@stockhome/shared";
|
import {GENERAL_ERROR_CODE, PRODUCT_ERROR_CODE} from "@stockhome/shared";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
import {authenticate} from "../../services/tokenService.js";
|
import {authenticate} from "../../services/tokenService";
|
||||||
import {allStorages, deleteStorage, newStorage, updateStorage,} from "./database/storage.database.ts";
|
import {allStorages, deleteStorage, newStorage, updateStorage,} from "./database/storage.database";
|
||||||
import {GENERAL_ERROR_CODE, STORAGE_ERROR_CODE} from "@stockhome/shared";
|
import {GENERAL_ERROR_CODE, STORAGE_ERROR_CODE} from "@stockhome/shared";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
import {authenticate, generateToken} from "../../services/tokenService.ts";
|
import {authenticate, generateToken} from "../../services/tokenService";
|
||||||
import {changePassword, findUser, getSettings, loginUser, updateSettings,} from "./database/users.database.ts";
|
import {changePassword, findUser, getSettings, loginUser, updateSettings,} from "./database/users.database";
|
||||||
import {GENERAL_ERROR_CODE, USER_ERROR_CODE} from "@stockhome/shared";
|
import {GENERAL_ERROR_CODE, USER_ERROR_CODE} from "@stockhome/shared";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|||||||
+5
-4
@@ -5,9 +5,10 @@ import dotenv from "dotenv";
|
|||||||
import mysql, {type ResultSetHeader, type RowDataPacket} from "mysql2";
|
import mysql, {type ResultSetHeader, type RowDataPacket} from "mysql2";
|
||||||
import {readFile} from "fs/promises";
|
import {readFile} from "fs/promises";
|
||||||
// frontend routes
|
// frontend routes
|
||||||
import userRouter from "./routes/app/users.route.ts";
|
import userRouter from "./routes/app/users.route";
|
||||||
import productRouter from "./routes/app/products.route.ts";
|
import productRouter from "./routes/app/products.route";
|
||||||
import storageRouter from "./routes/app/storage.route.ts";
|
import storageRouter from "./routes/app/storage.route";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const app = express();
|
const app = express();
|
||||||
@@ -55,7 +56,7 @@ const runStartup = async (port: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (firstStartupValue !== "false") {
|
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 schemaSql = await readFile(schemaPath, "utf8");
|
||||||
const statements = schemaSql
|
const statements = schemaSql
|
||||||
.split(";")
|
.split(";")
|
||||||
|
|||||||
+23
-32
@@ -1,45 +1,36 @@
|
|||||||
{
|
{
|
||||||
// Visit https://aka.ms/tsconfig to read more about this file
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
// File Layout
|
"composite": true,
|
||||||
// "rootDir": "./src",
|
"rootDir": ".",
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
// Environment Settings
|
"module": "CommonJS",
|
||||||
// See also https://aka.ms/tsconfig/module
|
"target": "ES2022",
|
||||||
"module": "esnext",
|
"moduleResolution": "Node",
|
||||||
"target": "esnext",
|
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"moduleResolution": "bundler",
|
"allowSyntheticDefaultImports": true,
|
||||||
// For nodejs:
|
"ignoreDeprecations": "6.0",
|
||||||
// "lib": ["esnext"],
|
|
||||||
"types": [
|
"types": [
|
||||||
"node"
|
"node"
|
||||||
],
|
],
|
||||||
// and npm install -D @types/node
|
|
||||||
|
|
||||||
// Other Outputs
|
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declaration": 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,
|
"strict": true,
|
||||||
"jsx": "react-jsx",
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"noUncheckedSideEffectImports": true,
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist",
|
||||||
|
"**/vite.config.ts",
|
||||||
|
"**/vite.config.*",
|
||||||
|
"**/*.config.ts",
|
||||||
|
"**/*.config.*"
|
||||||
|
],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "../shared"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
+5
-3
@@ -19,8 +19,8 @@ services:
|
|||||||
backend:
|
backend:
|
||||||
container_name: stockhome-backend
|
container_name: stockhome-backend
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: backend/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- "8004:8004"
|
- "8004:8004"
|
||||||
environment:
|
environment:
|
||||||
@@ -39,7 +39,9 @@ services:
|
|||||||
container_name: stockhome-frontend
|
container_name: stockhome-frontend
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
build: ./frontend
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: frontend/Dockerfile
|
||||||
environment:
|
environment:
|
||||||
BACKEND_HOST: ${BACKEND_HOST}
|
BACKEND_HOST: ${BACKEND_HOST}
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
+12
-4
@@ -3,17 +3,25 @@ FROM node:22-alpine AS builder
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
|
COPY backend/package.json backend/
|
||||||
|
COPY frontend/package.json frontend/
|
||||||
|
COPY shared/package.json shared/
|
||||||
|
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
COPY . .
|
COPY shared/ shared/
|
||||||
RUN npm run build
|
COPY frontend/ frontend/
|
||||||
|
|
||||||
|
# Build shared first, then frontend
|
||||||
|
RUN npm run build --workspace=shared
|
||||||
|
RUN npm run build --workspace=frontend
|
||||||
|
|
||||||
FROM nginx:alpine AS runner
|
FROM nginx:alpine AS runner
|
||||||
|
|
||||||
WORKDIR /usr/share/nginx/html
|
WORKDIR /usr/share/nginx/html
|
||||||
COPY --from=builder /app/dist .
|
COPY --from=builder /app/frontend/dist .
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/templates/default.conf.template
|
COPY frontend/nginx.conf /etc/nginx/templates/default.conf.template
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
Generated
-5116
File diff suppressed because it is too large
Load Diff
+23
-10
@@ -1,13 +1,26 @@
|
|||||||
{
|
{
|
||||||
"files": [],
|
|
||||||
"references": [
|
|
||||||
{ "path": "./tsconfig.app.json" },
|
|
||||||
{ "path": "./tsconfig.node.json" }
|
|
||||||
],
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "esnext",
|
"target": "ES2022",
|
||||||
"target": "esnext",
|
"useDefineForClassFields": true,
|
||||||
"esModuleInterop": true,
|
"lib": [
|
||||||
"moduleResolution": "node"
|
"ES2022",
|
||||||
}
|
"DOM",
|
||||||
|
"DOM.Iterable"
|
||||||
|
],
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"types": [
|
||||||
|
"vite/client"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
Generated
+29
-1351
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
"name": "@stockhome/shared",
|
"name": "@stockhome/shared",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"type": "module",
|
"type": "commonjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "barrelsby --directory src --delete --single",
|
"prebuild": "barrelsby --directory src --delete --single",
|
||||||
"build": "tsc",
|
"build": "tsc -b",
|
||||||
"lint": "eslint ."
|
"lint": "eslint ."
|
||||||
},
|
},
|
||||||
"main": "./dist/src/index.js",
|
"main": "./dist/src/index.js",
|
||||||
"types": "./dist/src/index.d.ts",
|
"types": "./dist/src/index.d.ts",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"barrelsby": "^2.8.1",
|
"barrelsby": "^2.8.1",
|
||||||
"vite-plugin-dts": "^5.0.3"
|
"typescript": "~6.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-49
@@ -1,55 +1,17 @@
|
|||||||
{
|
{
|
||||||
// Visit https://aka.ms/tsconfig to read more about this file
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
// File Layout
|
"composite": true,
|
||||||
// "rootDir": "./src",
|
|
||||||
"outDir": "./dist",
|
|
||||||
// Environment Settings
|
|
||||||
// See also https://aka.ms/tsconfig/module
|
|
||||||
"target": "esnext",
|
|
||||||
"types": [],
|
|
||||||
// For nodejs:
|
|
||||||
// "lib": ["esnext"],
|
|
||||||
// "types": ["node"],
|
|
||||||
// and npm install -D @types/node
|
|
||||||
|
|
||||||
// Other Outputs
|
|
||||||
"sourceMap": true,
|
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
// Stricter Typechecking Options
|
"outDir": "./dist",
|
||||||
"noUncheckedIndexedAccess": true,
|
"module": "CommonJS",
|
||||||
"exactOptionalPropertyTypes": true,
|
"target": "ES2022",
|
||||||
// Style Options
|
"moduleResolution": "Node",
|
||||||
// "noImplicitReturns": true,
|
|
||||||
// "noImplicitOverride": true,
|
|
||||||
// "noUnusedLocals": true,
|
|
||||||
// "noUnusedParameters": true,
|
|
||||||
// "noFallthroughCasesInSwitch": true,
|
|
||||||
// "noPropertyAccessFromIndexSignature": true,
|
|
||||||
|
|
||||||
// Recommended Options
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"noUncheckedSideEffectImports": true,
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"skipLibCheck": true,
|
||||||
"experimentalDecorators": true,
|
"ignoreDeprecations": "6.0"
|
||||||
"emitDecoratorMetadata": true,
|
},
|
||||||
"module": "esnext",
|
"include": [
|
||||||
"moduleResolution": "bundler",
|
"src/**/*.ts"
|
||||||
"resolveJsonModule": true,
|
]
|
||||||
"isolatedModules": true,
|
|
||||||
"noEmit": true,
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"noImplicitThis": true,
|
|
||||||
"noUnusedLocals": false,
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"allowJs": true,
|
|
||||||
"incremental": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { defineConfig } from "vite";
|
|
||||||
import dts from "vite-plugin-dts";
|
|
||||||
|
|
||||||
// https://vite.dev/config/
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [
|
|
||||||
dts(),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./shared"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./backend"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user