🚧 Making bot production ready

This commit is contained in:
Axel Olausson Holtenäs 2022-10-23 17:27:46 +02:00
parent ec8b526d49
commit d8c3492732
No known key found for this signature in database
GPG key ID: BEDBB4D61E6C8462
6 changed files with 13464 additions and 51 deletions

1
.gitignore vendored
View file

@ -2,7 +2,6 @@ json.sqlite
node_modules
.env
config.json
package-lock.json
src/config/

View file

@ -1,19 +1,34 @@
FROM node:19
LABEL maintainer="xyter@zyner.org"
WORKDIR /usr
WORKDIR /build
COPY package.json ./
COPY tsconfig.json ./
COPY src ./src
COPY prisma ./prisma
RUN ls -a
COPY package* .
RUN npm install
COPY . .
RUN npm run build
RUN npx -y tsc
## this is stage two , where the app actually runs
WORKDIR /app
FROM node:19
RUN cp -r /build/build/* .
RUN cp -r /build/node_modules .
WORKDIR /usr
CMD [ "node", "." ]
COPY package.json ./
COPY prisma ./
RUN npm install --omit=dev
COPY --from=0 /usr/dist .
RUN npx prisma migrate deploy
CMD ["node","index.js"]

View file

@ -1,41 +1,56 @@
# Not working yet due to change from Mongoose to Prisma
version: "3"
version: "3.7"
services:
app:
image: zyner/xyter:latest
restart: unless-stopped
# build: .
stdin_open: true
tty: true
container_name: app
restart: always
build: .
env_file: .env
volumes:
- ./logs:/app/logs
- ./logs:/usr/logs
environment:
- DISCORD_TOKEN=DISCORD_TOKEN
- DISCORD_CLIENT_ID=DISCORD_CLIENT_ID
- DISCORD_GUILD_ID=DISCORD_GUILD_ID
- MONGO_URL=mongodb://MONGO_USER:MONGO_PASS@mongodb:27017/admin?retryWrites=true&w=majority
- ENCRYPTION_ALGORITHM=ENCRYPTION_ALGORITHM
- ENCRYPTION_SECRET=ENCRYPTION_SECRET
- EMEBD_COLOR_SUCCESS=EMEBD_COLOR_SUCCESS
- EMBED_COLOR_WAIT=EMBED_COLOR_WAIT
- EMBED_COLOR_ERROR=EMBED_COLOR_ERROR
- EMBED_FOOTER_TEXT=EMBED_FOOTER_TEXT
- EMBED_FOOTER_ICON=EMBED_FOOTER_ICON
- LOG_LEVEL=LOG_LEVEL
- REPUTATION_TIMEOUT=REPUTATION_TIMEOUT
- BOT_HOSTER_NAME=BOT_HOSTER_NAME
- BOT_HOSTER_URL=BOT_HOSTER_URL
- NODE_ENV=production
depends_on:
- mongodb
- DATABASE_URL="file:./dev.db"
mongodb:
image: mongo:latest
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: MONGO_USER
MONGO_INITDB_ROOT_PASSWORD: MONGO_PASS
volumes:
- ./database:/data/db
volumes:
xyter-testdb:
# # Not working yet due to change from Mongoose to Prisma
# version: "3"
# services:
# app:
# image: zyner/xyter:latest
# restart: unless-stopped
# # build: .
# stdin_open: true
# tty: true
# volumes:
# - ./logs:/app/logs
# environment:
# - DISCORD_TOKEN=DISCORD_TOKEN
# - DISCORD_CLIENT_ID=DISCORD_CLIENT_ID
# - DISCORD_GUILD_ID=DISCORD_GUILD_ID
# - MONGO_URL=mongodb://MONGO_USER:MONGO_PASS@mongodb:27017/admin?retryWrites=true&w=majority
# - ENCRYPTION_ALGORITHM=ENCRYPTION_ALGORITHM
# - ENCRYPTION_SECRET=ENCRYPTION_SECRET
# - EMEBD_COLOR_SUCCESS=EMEBD_COLOR_SUCCESS
# - EMBED_COLOR_WAIT=EMBED_COLOR_WAIT
# - EMBED_COLOR_ERROR=EMBED_COLOR_ERROR
# - EMBED_FOOTER_TEXT=EMBED_FOOTER_TEXT
# - EMBED_FOOTER_ICON=EMBED_FOOTER_ICON
# - LOG_LEVEL=LOG_LEVEL
# - REPUTATION_TIMEOUT=REPUTATION_TIMEOUT
# - BOT_HOSTER_NAME=BOT_HOSTER_NAME
# - BOT_HOSTER_URL=BOT_HOSTER_URL
# - NODE_ENV=production
# depends_on:
# - mongodb
# mongodb:
# image: mongo:latest
# restart: unless-stopped
# environment:
# MONGO_INITDB_ROOT_USERNAME: MONGO_USER
# MONGO_INITDB_ROOT_PASSWORD: MONGO_PASS
# volumes:
# - ./database:/data/db

13381
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -2,13 +2,15 @@
"name": "xyter",
"version": "3.1.0",
"description": "Earn credits while chatting! And more",
"main": "src/index.ts",
"main": "dist/index.js",
"scripts": {
"dev": "tsc --watch & nodemon dist",
"build": "tsc -p .",
"prisma:generate": "prisma generate",
"test": "jest",
"start": "nodemon src/index.ts",
"start": "node dist",
"prettier-format": "prettier \"src/**/*.ts\" --write",
"lint": "eslint ./src --ext .ts",
"prepare": "husky install"
"lint": "eslint ./src --ext .ts"
},
"keywords": [
"Zyner",

View file

@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es2022",
"target": "es6",
"module": "CommonJS",
"allowJs": true,
"skipLibCheck": true,
@ -11,7 +11,8 @@
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"isolatedModules": true,
"outDir": "./build",
"outDir": "./dist",
"rootDir": "./src",
"resolveJsonModule": true,
"typeRoots": ["/types/common", "./node_modules/@types"]
},