diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..22e420b --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/db/shop.db b/db/shop.db new file mode 100644 index 0000000..672dbc4 Binary files /dev/null and b/db/shop.db differ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..43e8e52 --- /dev/null +++ b/docker-compose.yml @@ -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/ \ No newline at end of file diff --git a/shop.db b/shop.db deleted file mode 100644 index e69de29..0000000 diff --git a/src/config/config.js b/src/config/config.js index 0474ace..96f814e 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -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 }; \ No newline at end of file diff --git a/src/config/database.js b/src/config/database.js index 8062db4..ec9b8cc 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -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);