feat(release): Adds docker support
This commit is contained in:
parent
a3c1bae6db
commit
68368ab916
7 changed files with 79 additions and 3 deletions
|
|
@ -30,6 +30,7 @@ export class Services {
|
|||
container.set<Logger>(logger, 'logger');
|
||||
|
||||
const database = new DatabaseConnection(env.database);
|
||||
database.connect()
|
||||
container.set<DatabaseConnection>(database);
|
||||
|
||||
const eventHandler = new EventHandler();
|
||||
|
|
|
|||
|
|
@ -3,12 +3,22 @@ import Sqlite3 from "better-sqlite3";
|
|||
import Database from "better-sqlite3";
|
||||
import {Container} from "../Container/Container";
|
||||
import {Logger} from "log4js";
|
||||
import path from "node:path";
|
||||
import * as fs from "node:fs";
|
||||
|
||||
export class DatabaseConnection {
|
||||
private database: Sqlite3.Database;
|
||||
|
||||
constructor(env: DatabaseEnvironment) {
|
||||
this.database = new Database(env.path, {
|
||||
constructor(private readonly env: DatabaseEnvironment) {
|
||||
}
|
||||
|
||||
public connect() {
|
||||
const directory = path.dirname(this.env.path);
|
||||
fs.mkdirSync(directory, {
|
||||
recursive: true
|
||||
})
|
||||
|
||||
this.database = new Database(this.env.path, {
|
||||
nativeBinding: "node_modules/better-sqlite3/build/Release/better_sqlite3.node",
|
||||
})
|
||||
this.database.pragma('journal_mode = WAL');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import dotenv from "dotenv";
|
||||
import path from "node:path";
|
||||
import * as fs from "node:fs";
|
||||
import {dot} from "node:test/reporters";
|
||||
|
||||
type DiscordEnvironment = {
|
||||
token: string;
|
||||
|
|
@ -27,8 +29,14 @@ export class Environment {
|
|||
}
|
||||
|
||||
public setup() {
|
||||
const dotenvPath = path.resolve(__dirname, "../environment/.env");
|
||||
|
||||
if (!fs.existsSync(dotenvPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dotenv.config({
|
||||
path: path.resolve(__dirname, "../environment/.env"),
|
||||
path: dotenvPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue