fix: docker container are starting

This commit is contained in:
2026-07-08 13:37:21 +02:00
parent c6bba8a40c
commit 3a5c16031a
18 changed files with 176 additions and 7710 deletions
+1
View File
@@ -19,6 +19,7 @@
.LSOverride
node_modules
tsconfig.tsbuildinfo
# Icon must end with two \r
+29 -5
View File
@@ -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"]
-1096
View File
File diff suppressed because it is too large Load Diff
+4 -8
View File
@@ -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"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
import express from "express";
import dotenv from "dotenv";
import {authenticate} from "../../services/tokenService.ts";
import {authenticate} from "../../services/tokenService";
import {
allProducts,
deleteProduct,
@@ -8,7 +8,7 @@ import {
productDetails,
setAmount,
updateItem,
} from "./database/products.database.ts";
} from "./database/products.database";
import {GENERAL_ERROR_CODE, PRODUCT_ERROR_CODE} from "@stockhome/shared";
dotenv.config();
+2 -2
View File
@@ -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();
+2 -2
View File
@@ -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
View File
@@ -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(";")
+23 -32
View File
@@ -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"
}
]
}
+5 -3
View File
@@ -19,8 +19,8 @@ services:
backend:
container_name: stockhome-backend
build:
context: ./backend
dockerfile: Dockerfile
context: .
dockerfile: backend/Dockerfile
ports:
- "8004:8004"
environment:
@@ -39,7 +39,9 @@ services:
container_name: stockhome-frontend
ports:
- "80:80"
build: ./frontend
build:
context: .
dockerfile: frontend/Dockerfile
environment:
BACKEND_HOST: ${BACKEND_HOST}
depends_on:
+12 -4
View File
@@ -3,17 +3,25 @@ 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 . .
RUN npm run build
COPY shared/ shared/
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
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
CMD ["nginx", "-g", "daemon off;"]
-5116
View File
File diff suppressed because it is too large Load Diff
+23 -10
View File
@@ -1,13 +1,26 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
],
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"esModuleInterop": true,
"moduleResolution": "node"
}
"target": "ES2022",
"useDefineForClassFields": true,
"lib": [
"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"
]
}
+29 -1351
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -2,16 +2,16 @@
"name": "@stockhome/shared",
"private": true,
"version": "1.0.0",
"type": "module",
"type": "commonjs",
"scripts": {
"prebuild": "barrelsby --directory src --delete --single",
"build": "tsc",
"build": "tsc -b",
"lint": "eslint ."
},
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"devDependencies": {
"barrelsby": "^2.8.1",
"vite-plugin-dts": "^5.0.3"
"typescript": "~6.0.2"
}
}
+11 -49
View File
@@ -1,55 +1,17 @@
{
// Visit https://aka.ms/tsconfig to read more about this file
"compilerOptions": {
// File Layout
// "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,
"composite": true,
"declaration": true,
"declarationMap": true,
// Stricter Typechecking Options
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
// Style Options
// "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,
"outDir": "./dist",
"module": "CommonJS",
"target": "ES2022",
"moduleResolution": "Node",
"strict": true,
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUnusedLocals": false,
"jsx": "react-jsx",
"noFallthroughCasesInSwitch": true,
"allowJs": true,
"incremental": true
}
"skipLibCheck": true,
"ignoreDeprecations": "6.0"
},
"include": [
"src/**/*.ts"
]
}
-9
View File
@@ -1,9 +0,0 @@
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
// https://vite.dev/config/
export default defineConfig({
plugins: [
dts(),
],
});
+11
View File
@@ -0,0 +1,11 @@
{
"files": [],
"references": [
{
"path": "./shared"
},
{
"path": "./backend"
}
]
}