This commit is contained in:
Artyom Ashirov 2024-11-14 16:44:00 +03:00
parent 45ad916f61
commit 3872ddbb68
6 changed files with 34 additions and 6 deletions

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM node:22
WORKDIR /app
COPY package*.json /app/
COPY src/ /app/src/
COPY db/shop.db /app/shop.db
RUN npm install
CMD ["node", "src/index.js"]

BIN
db/shop.db Normal file

Binary file not shown.

17
docker-compose.yml Normal file
View File

@ -0,0 +1,17 @@
version: "3.3"
services:
telegram_shop_prod:
build:
context: .
dockerfile: ./Dockerfile
hostname: telegram_shop_prod
container_name: telegram_shop_prod
restart: always
environment:
- BOT_TOKEN=7626758249:AAEdcbXJpW1VsnJJtc8kZ5VBsYMFR242wgk
- ADMIN_IDS=732563549,390431690
- SUPPORT_LINK=https://t.me/neroworm
- CATALOG_PATH=./catalog
volumes:
- ./db:/app/db/

View File

View File

@ -1,6 +1,6 @@
export default {
BOT_TOKEN: "7626758249:AAEdcbXJpW1VsnJJtc8kZ5VBsYMFR242wgk",
ADMIN_IDS: ["732563549", "390431690"],
SUPPORT_LINK: "https://t.me/neroworm",
CATALOG_PATH: "./catalog"
BOT_TOKEN: process.env.BOT_TOKEN,
ADMIN_IDS: process.env.ADMIN_IDS.split(","),
SUPPORT_LINK: process.env.SUPPORT_LINK,
CATALOG_PATH: process.env.CATALOG_PATH
};

View File

@ -4,7 +4,7 @@ import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const DB_PATH = new URL('../../shop.db', import.meta.url).pathname;
const DB_PATH = new URL('../../db/shop.db', import.meta.url).pathname;
// Create database with verbose mode for better error reporting
const db = new sqlite3.Database(DB_PATH, sqlite3.OPEN_CREATE | sqlite3.OPEN_READWRITE, (err) => {
@ -243,8 +243,8 @@ const initDb = async () => {
// Initialize the database
(async () => {
await cleanUpInvalidForeignKeys();
await initDb();
await cleanUpInvalidForeignKeys();
})().catch(error => {
console.error('Database initialization failed:', error);
process.exit(1);