Merge pull request 'docker' (#10) from feature/docker into main
This commit is contained in:
commit
40400ee2b0
11
Dockerfile
Normal file
11
Dockerfile
Normal 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
BIN
db/shop.db
Normal file
Binary file not shown.
17
docker-compose.yml
Normal file
17
docker-compose.yml
Normal 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/
|
@ -1,6 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
BOT_TOKEN: "7626758249:AAEdcbXJpW1VsnJJtc8kZ5VBsYMFR242wgk",
|
BOT_TOKEN: process.env.BOT_TOKEN,
|
||||||
ADMIN_IDS: ["732563549", "390431690"],
|
ADMIN_IDS: process.env.ADMIN_IDS.split(","),
|
||||||
SUPPORT_LINK: "https://t.me/neroworm",
|
SUPPORT_LINK: process.env.SUPPORT_LINK,
|
||||||
CATALOG_PATH: "./catalog"
|
CATALOG_PATH: process.env.CATALOG_PATH
|
||||||
};
|
};
|
@ -4,7 +4,7 @@ import { dirname } from 'path';
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.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
|
// Create database with verbose mode for better error reporting
|
||||||
const db = new sqlite3.Database(DB_PATH, sqlite3.OPEN_CREATE | sqlite3.OPEN_READWRITE, (err) => {
|
const db = new sqlite3.Database(DB_PATH, sqlite3.OPEN_CREATE | sqlite3.OPEN_READWRITE, (err) => {
|
||||||
@ -243,8 +243,8 @@ const initDb = async () => {
|
|||||||
|
|
||||||
// Initialize the database
|
// Initialize the database
|
||||||
(async () => {
|
(async () => {
|
||||||
await cleanUpInvalidForeignKeys();
|
|
||||||
await initDb();
|
await initDb();
|
||||||
|
await cleanUpInvalidForeignKeys();
|
||||||
})().catch(error => {
|
})().catch(error => {
|
||||||
console.error('Database initialization failed:', error);
|
console.error('Database initialization failed:', error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user