Skip to content

Commit

Permalink
merge: #73 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
barthofu authored Oct 18, 2022
2 parents d60da5d + 2a1acf0 commit 93f7a41
Show file tree
Hide file tree
Showing 98 changed files with 1,035 additions and 648 deletions.
19 changes: 9 additions & 10 deletions .docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
## build runner
FROM node:16.17-alpine as build-runner
FROM node:16.17-buster-slim as build-runner

# Set temp directory
WORKDIR /tmp/app

# Move package.json and package-lock.json
COPY package.json .
COPY package-lock.json .
COPY src ./src

# Install dependencies from package-lock.json
RUN npm ci && npm cache clean --force

# Move source files
COPY src ./src
# and install dependencies for plugins (because postinstall script doesn't work in docker)
RUN npm ci

COPY .swcrc .
COPY tsconfig.json .
Expand All @@ -21,7 +20,7 @@ COPY tsconfig.json .
RUN npm run build

## producation runner
FROM node:16.17-alpine as prod-runner
FROM node:16.17-buster-slim as prod-runner

# set production mode
ARG NODE_ENV=production
Expand All @@ -34,12 +33,12 @@ WORKDIR /app
COPY --from=build-runner /tmp/app/package.json /app/package.json
COPY --from=build-runner /tmp/app/package-lock.json /app/package-lock.json

# Install dependencies from package-lock.json
RUN npm ci --omit=dev

# Move build files
COPY --from=build-runner /tmp/app/build /app/build
# COPY assets /app/assets

# Install dependencies from package-lock.json
# and install dependencies for plugins (because plugins:install script doesn't work in docker)
RUN npm ci --omit=dev && npm cache clean --force

# Finaly start the bot
CMD ["node", "build/main.js"]
34 changes: 29 additions & 5 deletions .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,47 @@
"target": "es2021",
"baseUrl": "./",
"paths": {
"@types": ["src/utils/types"],

"@decorators": ["src/utils/decorators"],
"@decorators/*": ["src/plugins/*/utils/decorators"],

"@errors": ["src/utils/errors"],
"@errors/*": ["src/plugins/*/utils/errors"],

"@entities": ["src/entities"],
"@entities/*": ["src/plugins/*/entities"],

"@guards": ["src/guards"],
"@guards/*": ["src/plugins/*/guards"],

"@services": ["src/services"],
"@services/*": ["src/plugins/*/services"],

"@i18n": ["src/i18n"],
"@i18n/*": ["src/plugins/*/i18n"],

"@config": ["src/config"],

"@core/*": ["src/core/*"],
"@utils/*": ["src/utils/*"],
"@api/*": ["src/api/*"]
"@config/*": ["src/plugins/*/config"],

"@utils/classes": ["src/utils/classes"],
"@utils/classes/*": ["src/plugins/*/utils/classes"],

"@utils/functions": ["src/utils/functions"],
"@utils/functions/*": ["src/plugins/*/utils/functions"],

"@api/controllers": ["src/api/controllers"],
"@api/controllers/*": ["src/plugins/*/api/controllers"],

"@api/middlewares": ["src/api/middlewares"],
"@api/middlewares/*": ["src/plugins/*/api/middlewares"],

"@api/server": ["src/api/server.ts"]
},
"transform": {
"decoratorMetadata": true
}
},
"exclude": ["node_modules", ".git"],
"module": {
"type": "commonjs"
}
Expand Down
17 changes: 15 additions & 2 deletions mikro-orm.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
import { mikroORMConfig } from './src/config/database'
import { mikroORMConfig } from "./src/config/database"
import * as entities from "@entities"
import { PluginsManager } from "@services"
import { Options } from "@mikro-orm/core"
import { resolveDependency } from "@utils/functions"

export default async () => {
const pluginsManager = await resolveDependency(PluginsManager)
await pluginsManager.loadPlugins()

return {
...mikroORMConfig[process.env.NODE_ENV || 'development'] as Options<DatabaseDriver>,
entities: [...Object.values(entities), ...pluginsManager.getEntities()]
}
}

export default mikroORMConfig[process.env.NODE_ENV || 'development']
Loading

0 comments on commit 93f7a41

Please sign in to comment.