diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..efa748a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.vscode +.husky +.github +.cspell +.env +node_modules \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9fe2862..ff5dc1a 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,8 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + + +# Docker +database +docker-compose.local.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index bf1e149..af5581d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,16 @@ FROM node:16 -LABEL maintainer="me@jqshuv.xyz" -LABEL org.opencontainers.image.source https://github.com/ZynerOrg/xyter -LABEL org.opencontainers.image.description "An multi-purpose discord.js bot." -LABEL org.opencontainers.image.licenses=GPL-3.0-only - +LABEL maintainer="xyter@zyner.org" WORKDIR /app -LABEL maintainer="me@jqshuv.xyz" -LABEL org.opencontainers.image.source https://github.com/ZynerOrg/xyter -LABEL org.opencontainers.image.description "An multi-purpose discord.js bot." -LABEL org.opencontainers.image.licenses=GPL-3.0-only - COPY package* . RUN npm install COPY . . -RUN mv src/config_docker src/config -RUN npx tsc - -RUN npx tsc -v > /app/tsc.log -RUN npm -v > /app/npm.log -RUN node -v > /app/node.log +RUN npx -y tsc WORKDIR /app/build -CMD [ "npx", "nodemon" ] \ No newline at end of file +CMD [ "node", "." ] \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..5765287 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,33 @@ +services: + app: + depends_on: + - mongodb + build: . + restart: unless-stopped + environment: + - DISCORD_TOKEN=YOUR TOKEN + - DISCORD_CLIENT_ID=YOUR CLIENT ID + - DISCORD_GUILD_ID=YOUR GUILD ID + ### LEAVE THIS AS IT IS! ### + - MONGO_URL=mongodb://mongodb:27017/xyter?retryWrites=true&w=majority + ############################ + - ENCRYPTION_ALGORITHM=aes-256-ctr + - ENCRYPTION_SECRET=A RANDOM STRING WITH LENGTH OF 32 + - EMEBD_COLOR_SUCCESS=#22bb33 + - EMBED_COLOR_WAIT=#f0ad4e + - EMBED_COLOR_ERROR=#bb2124 + - EMBED_FOOTER_TEXT=https://github.com/ZynerOrg/xyter + - EMBED_FOOTER_ICON=https://github.com/ZynerOrg.png + - LOG_LEVEL=silly + - REPUTATION_TIMEOUT=86400 + - BOT_HOSTER_NAME=Zyner + - BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster + - NODE_ENV=production + stdin_open: true + tty: true + mongodb: + image: mongo:4.2.21 + restart: unless-stopped + volumes: + - ./logs:/app/build/logs + - ./database:/data/db diff --git a/docker-compose.yml b/docker-compose.yml index 007f637..9b08008 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,32 +2,32 @@ services: app: depends_on: - mongodb - build: . + image: zyner/xyter:2022.07.0 restart: unless-stopped environment: - # You can leave this as-is. - - DB_HOST=mongodb - - DB_USER=mongouser - - DB_PASSWORD=mongopasword - - DB_NAME=xyter - - DB_PORT=27017 - # You have to set these values! - - DISCORD_TOKEN=YOUR_DISCORD_TOKEN - - DISCORD_CLIENT_ID=YOUR_CLIENT_ID - - DISCORD_DEV_GUILD_ID=YOUR_DEV_GUILD_ID - - HOSTER_NAME=YOUR_HOSTER_NAME - - NODE_ENV=development + - DISCORD_TOKEN=YOUR TOKEN + - DISCORD_CLIENT_ID=YOUR CLIENT ID + - DISCORD_GUILD_ID=YOUR GUILD ID + ### LEAVE THIS AS IT IS! ### + - MONGO_URL=mongodb://mongodb:27017/xyter?retryWrites=true&w=majority + ############################ + - ENCRYPTION_ALGORITHM=aes-256-ctr + - ENCRYPTION_SECRET=A RANDOM STRING WITH LENGTH OF 32 + - EMEBD_COLOR_SUCCESS=#22bb33 + - EMBED_COLOR_WAIT=#f0ad4e + - EMBED_COLOR_ERROR=#bb2124 + - EMBED_FOOTER_TEXT=https://github.com/ZynerOrg/xyter + - EMBED_FOOTER_ICON=https://github.com/ZynerOrg.png + - LOG_LEVEL=silly + - REPUTATION_TIMEOUT=86400 + - BOT_HOSTER_NAME=Zyner + - BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster + - NODE_ENV=production stdin_open: true tty: true mongodb: - image: mongo:latest + image: mongo:4.2.21 restart: unless-stopped - environment: - - MONGO_INITDB_ROOT_USERNAME=mongouser - - MONGO_INITDB_ROOT_PASSWORD=mongopasword - ports: - - $MONGODB_LOCAL_PORT:27017 volumes: - - db:/data/db -volumes: - db: + - ./logs:/app/build/logs + - ./database:/data/db diff --git a/src/config_docker/database.ts b/src/config_docker/database.ts deleted file mode 100644 index 0d51b49..0000000 --- a/src/config_docker/database.ts +++ /dev/null @@ -1,7 +0,0 @@ -// MongoDB connection string - -const { DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME } = process.env; - -const mongoUrl = `mongodb://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?authSource=admin`; - -export const url = mongoUrl; diff --git a/src/config_docker/discord.ts b/src/config_docker/discord.ts deleted file mode 100644 index f3f9c4a..0000000 --- a/src/config_docker/discord.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Intents } from "discord.js"; // discord.js - -// Discord API token -export const token = process.env["DISCORD_TOKEN"]; - -// Discord API id -export const clientId = process.env["DISCORD_CLIENT_ID"]; - -// Discord API intents -export const intents = [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES, - Intents.FLAGS.GUILD_MEMBERS, -]; diff --git a/src/config_docker/embed.ts b/src/config_docker/embed.ts deleted file mode 100644 index 81430e5..0000000 --- a/src/config_docker/embed.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Dependencies -import { ColorResolvable } from "discord.js"; - -// Color for successfully actions -export const successColor: ColorResolvable = "#22bb33"; - -// Color for waiting actions -export const waitColor: ColorResolvable = "#f0ad4e"; - -// Color for error actions -export const errorColor: ColorResolvable = "#bb2124"; - -// Footer text -export const footerText = - process.env["EMBED_FOOTER_TEXT"] || "https://github.com/ZynerOrg/xyter"; - -// Footer icon -export const footerIcon = - process.env["EMBED_FOOTER_ICON"] || "https://github.com/ZynerOrg.png"; diff --git a/src/config_docker/encryption.ts b/src/config_docker/encryption.ts deleted file mode 100644 index d54eb43..0000000 --- a/src/config_docker/encryption.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Encryption algorithm -export const algorithm = "aes-256-ctr"; - -// Encryption secret (strictly 32 length) -export const secretKey = - process.env["SECRET_KEY"] || "h/f#Ts8w5sch5L:J*_gPW)]$'!4K.K.-"; diff --git a/src/config_docker/other.ts b/src/config_docker/other.ts deleted file mode 100644 index 96cc6c3..0000000 --- a/src/config_docker/other.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Development features - -let isDevMode: boolean; - -if (process.env["NODE_ENV"] == "production") { - isDevMode = false; -} else { - isDevMode = true; -} - -export const devMode = isDevMode; - -// Development guild -export const guildId = process.env["DISCORD_DEV_GUILD_ID"]; - -// Hoster name -export const hosterName = process.env["HOSTER_NAME"]; - -// Hoster Url -export const hosterUrl = - process.env["HOSTER_URL"] || - "https://xyter.zyner.org/customization/change-hoster"; - -// Winston log level -export const logLevel = "info"; diff --git a/src/config_docker/reputation.ts b/src/config_docker/reputation.ts deleted file mode 100644 index 064edc9..0000000 --- a/src/config_docker/reputation.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Timeout between repute someone (seconds) -export const timeout = 86400; // One day diff --git a/src/types/enviroment.d.ts b/src/types/enviroment.d.ts deleted file mode 100644 index 5a55579..0000000 --- a/src/types/enviroment.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2022 Joshua Schmitt -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -declare global { - namespace NodeJS { - interface ProcessEnv { - DB_HOST: string; - DB_PORT: string; - DB_USER: string; - DB_PASSWORD: string; - DISCORD_TOKEN: string; - DISCORD_CLIENT_ID: string; - DISCORD_DEV_GUILD_ID: string; - EMBED_FOOTER_TEXT: string; - EMBED_FOOTER_ICON: string; - SECRET_KEY: string; - DISCORD_DEV_GUILD_ID: string; - HOSTER_NAME: string; - HOSTER_URL: string; - NODE_ENV: string; - } - } -} - -export {};