diff --git a/.env.example b/.env.example deleted file mode 100644 index c4c18cf..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -TELEGRAM_BOT_TOKEN=8118888833:BBFr_C202uhbUS7PrjOLKjfeEA-Zq4LSMdA -TELEGRAM_BOT_WEBHOOK_URL=https://525e-7574-6204-49d7-6900-fc19-19db-d871-f583.ngrok-free.app diff --git a/_deploy/dev/.env.example b/_deploy/dev/.env.example new file mode 100644 index 0000000..f5df4c6 --- /dev/null +++ b/_deploy/dev/.env.example @@ -0,0 +1,5 @@ +COMPOSE_PROJECT_NAME=one_ton_daily_bot + +BOT_PORT=2000 +TELEGRAM_BOT_TOKEN=8118888833:BBFr_C202uhbUS7PrjOLKjfeEA-Zq4LSMdA +TELEGRAM_BOT_WEBHOOK_URL=https://a363-2a0b-6204-49d7-6900-f8fa-8992-d06f-46f2.ngrok-free.app diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..05cae96 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,40 @@ +FROM node:21 + +#ARG PORT + +# Prevent Puppeteer from downloading Chromium +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true +ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium" + +WORKDIR /app + +COPY . . + +RUN apt-get update && apt-get install libsqlite3-dev sqlite3 -y + +RUN npm install --verbose + +RUN apt-get update && apt-get install -y --no-install-recommends \ + fonts-liberation \ + libasound2 \ + libatk-bridge2.0-0 \ + libatk1.0-0 \ + libcups2 \ + libdrm2 \ + libgbm1 \ + libgtk-3-0 \ + libnspr4 \ + libnss3 \ + libx11-xcb1 \ + libxcomposite1 \ + libxdamage1 \ + libxrandr2 \ + xdg-utils \ + libu2f-udev \ + libxshmfence1 \ + libglu1-mesa \ + chromium \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +CMD [ "npm", "run", "start:dev" ] \ No newline at end of file diff --git a/db/database.sqlite b/client/db/database.sqlite old mode 100644 new mode 100755 similarity index 96% rename from db/database.sqlite rename to client/db/database.sqlite index de74425..dd8ccfd Binary files a/db/database.sqlite and b/client/db/database.sqlite differ diff --git a/client/package-lock.json b/client/package-lock.json index 38941cc..86dee80 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1622,6 +1622,20 @@ } } }, + "node_modules/@nestjs/cli/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/@nestjs/common": { "version": "10.4.15", "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.4.15.tgz", @@ -3125,9 +3139,9 @@ "license": "MIT" }, "node_modules/bare-events": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.5.2.tgz", - "integrity": "sha512-KSdMqLj1ZERZMP1PTmnLK7SqJu9z9/SbwUUPZly2puMtfVcytC+jl6mb/9XYiqq0PXcx1rNDS+Qvl1g54Lho6A==", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.5.3.tgz", + "integrity": "sha512-pCO3aoRJ0MBiRMu8B7vUga0qL3L7gO1+SW7ku6qlSsMLwuhaawnuvZDyzJY/kyC63Un0XAB0OPUcfF1eTO/V+Q==", "license": "Apache-2.0", "optional": true }, @@ -3306,9 +3320,9 @@ } }, "node_modules/browserslist": { - "version": "4.24.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.3.tgz", - "integrity": "sha512-1CPmv8iobE2fyRMV97dAcMVegvvWKxmq94hkLiAkUGwKVTyDLw33K+ZxiFrREKmmps4rIw6grcCFCnTMSZ/YiA==", + "version": "4.24.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.4.tgz", + "integrity": "sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==", "dev": true, "funding": [ { @@ -3632,9 +3646,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001690", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz", - "integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==", + "version": "1.0.30001692", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001692.tgz", + "integrity": "sha512-A95VKan0kdtrsnMubMKxEKUKImOPSuCpYgxSQBo036P5YYgVIcOYJEgt/txJWqObiRQeISNCfef9nvlQ0vbV7A==", "dev": true, "funding": [ { @@ -4545,9 +4559,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.77", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.77.tgz", - "integrity": "sha512-AnJSrt5JpRVgY6dgd5yccguLc5A7oMSF0Kt3fcW+Hp5WTuFbl5upeSFZbMZYy2o7jhmIhU8Ekrd82GhyXUqUUg==", + "version": "1.5.79", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.79.tgz", + "integrity": "sha512-nYOxJNxQ9Om4EC88BE4pPoNI8xwSFf8pU/BAeOl4Hh/b/i6V4biTAzwV7pXi3ARKeoYO5JZKMIXTryXSVer5RA==", "dev": true, "license": "ISC" }, @@ -11270,9 +11284,9 @@ } }, "node_modules/typescript": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", - "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -11370,9 +11384,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", - "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.2.tgz", + "integrity": "sha512-PPypAm5qvlD7XMZC3BujecnaOxwhrtoFR+Dqkk5Aa/6DssiH0ibKoketaj9w8LP7Bont1rYeoV5plxD7RTEPRg==", "dev": true, "funding": [ { @@ -11391,7 +11405,7 @@ "license": "MIT", "dependencies": { "escalade": "^3.2.0", - "picocolors": "^1.1.0" + "picocolors": "^1.1.1" }, "bin": { "update-browserslist-db": "cli.js" diff --git a/client/src/app.module.ts b/client/src/app.module.ts index a0f5aea..d9f6951 100644 --- a/client/src/app.module.ts +++ b/client/src/app.module.ts @@ -8,11 +8,13 @@ import { ConfigModule } from '@nestjs/config'; import { TypeOrmModule } from '@nestjs/typeorm'; import * as path from 'path'; +console.log(path.resolve(__dirname, '../db/database.sqlite')); + @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, - envFilePath: './../_deploy/dev/.env', + envFilePath: '../../.env', }), TelegrafModule.forRoot({ token: process.env.TELEGRAM_BOT_TOKEN, @@ -25,7 +27,7 @@ import * as path from 'path'; }), TypeOrmModule.forRoot({ type: 'sqlite', - database: path.resolve(__dirname, '../../db/database.sqlite'), + database: path.resolve(__dirname, '../db/database.sqlite'), entities: [__dirname + '/**/*.entity{.ts,.js}'], synchronize: true, }), @@ -34,4 +36,4 @@ import * as path from 'path'; controllers: [AppController], providers: [AppService, BotUpdate], }) -export class AppModule {} +export class AppModule { } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..305c2a9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +services: + bot: + build: + context: ./client + dockerfile: ./Dockerfile + + environment: + - TZ=Europe/Moscow + - NODE_ENV=development + - PORT=${BOT_PORT} + - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} + - TELEGRAM_BOT_WEBHOOK_URL=${TELEGRAM_BOT_WEBHOOK_URL} + # ports: + # - '${BOT_PORT}:${BOT_PORT}' + networks: + - one_ton_daily_bot_network + volumes: + # - ./client/src:/app/src + - ./client/db:/app/db + restart: unless-stopped + + # sqlitebrowser: + # image: linuxserver/sqlitebrowser + # ports: + # - "3000:3000" + # depends_on: + # - bot + # environment: + # - PUID=1000 + # - PGID=1000 + # - TZ=UTC + # - ENABLE_UWSGI=true + # volumes: + # - ../../db:/data/db + # networks: + # - one_ton_daily_bot_network + # restart: unless-stopped + # container_name: sqlitebrowser + + +networks: + one_ton_daily_bot_network: + +volumes: + db: + external: true \ No newline at end of file