Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
apps: [
{
name: "interchat",
script: "build/index.js",
env_production: {
NODE_ENV: "production"
},
autorestart: true
}
]
};

61 changes: 0 additions & 61 deletions .github/workflows/build.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
name: Create and publish a Docker image

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on: release

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
restart:
needs: [build-and-push-image]
name: run-container-on-self-hosted
runs-on: self-hosted
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
steps:
- name: Log in to the Container registry
run: echo ${{ secrets.GITHUB_TOKEN }} | sudo docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull latest image
run: sudo docker pull ghcr.io/discord-interchat/interchat
# - name: Run latest image
# run: sudo docker run -d --env-file ~/important/interchat-env ghcr.io/discord-interchat/interchat
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:21.7.0
WORKDIR /src

LABEL org.opencontainers.image.source=https://github.com/Discord-InterChat/InterChat

COPY src ./src
COPY locales ./locales
COPY prisma ./prisma
COPY tsconfig.json .
COPY package.json .
COPY yarn.lock .
COPY .yarn ./.yarn
COPY .yarnrc.yml .

RUN yarn
RUN yarn prisma generate

RUN yarn build
RUN yarn workspaces focus --production

EXPOSE 443
CMD ["yarn", "start"]
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "GPL-3.0-or-later",
"scripts": {
"start": "node .",
"start:prod": "pm2 start .ecosystem.config.js",
"build": "tsc --build",
"dev": "tsc-watch --outDir ./build --onSuccess \"node --trace-warnings .\"",
"register:commands": "node build/utils/RegisterCmdCli.js",
Expand All @@ -18,8 +19,8 @@
},
"type": "module",
"dependencies": {
"@prisma/client": "^5.10.2",
"@sentry/node": "^7.106.0",
"@prisma/client": "^5.11.0",
"@sentry/node": "^7.107.0",
"@tensorflow/tfjs-node": "^4.17.0",
"@top-gg/sdk": "^3.1.6",
"common-tags": "^1.8.2",
Expand All @@ -34,29 +35,30 @@
"lz-string": "^1.5.0",
"nsfwjs": "^3.0.0",
"parse-duration": "^1.1.0",
"pm2": "^5.3.1",
"sharp": "^0.33.2",
"source-map-support": "^0.5.21",
"winston": "^3.12.0"
},
"devDependencies": {
"@stylistic/eslint-plugin": "^1.6.3",
"@stylistic/eslint-plugin": "^1.7.0",
"@types/common-tags": "^1.8.4",
"@types/express": "^4.17.21",
"@types/i18n": "^0.13.10",
"@types/js-yaml": "^4.0.9",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.25",
"@types/lodash": "^4.17.0",
"@types/node": "^20.11.28",
"@types/source-map-support": "^0.5.10",
"cz-conventional-changelog": "^3.3.0",
"eslint": "8.57.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"prisma": "^5.10.2",
"prisma": "^5.11.0",
"standard-version": "^9.5.0",
"tsc-watch": "^6.0.4",
"typescript": "^5.4.2",
"typescript-eslint": "^7.1.1"
"typescript-eslint": "^7.2.0"
},
"config": {
"commitizen": {
Expand Down
5 changes: 2 additions & 3 deletions src/api/routes/dbl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import { VoteManager } from '../../managers/VoteManager.js';

// NOTE: testing this against top.gg only works in the production server
// to test locally use postman or something similar to send a POST request to http://localhost:443/dbl
const router: Router = Router();
const TopggWebhook = new Webhook(process.env.TOPGG_AUTH);

export default (voteManager: VoteManager) => {
router.post(
Router().post(
'/dbl',
TopggWebhook.listener((vote) => {
// emit the vote event to use in other files
voteManager?.emit('vote', vote);
}),
);
return router;
return Router();
};
2 changes: 1 addition & 1 deletion src/api/routes/nsfw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import sharp from 'sharp';
import jpeg from 'jpeg-js';

let nsfwModel;
const router: Router = Router();
const router = Router();

const imageToTensor = async (rawImageData: ArrayBuffer) => {
const jpegImg = await sharp(rawImageData).jpeg().toBuffer();
Expand Down
2 changes: 1 addition & 1 deletion src/managers/CommandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class CommandManager extends Factory {
}
else if (file.endsWith('.js') && file !== 'BaseCommand.js') {
const imported = await import(importPrefix + filePath);
const command = new imported.default();
const command: BaseCommand = new imported.default();

// if the command extends BaseCommand (ie. is not a subcommand), add it to the commands map
if (Object.getPrototypeOf(command.constructor) === BaseCommand) {
Expand Down
Loading