Skip to content

Commit 0ba2ad4

Browse files
committed
🏗 Setting up TypeOrm and improving Docker config
1 parent 5f96df9 commit 0ba2ad4

20 files changed

+794
-384
lines changed

.env.dist

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ NODE_ENV=
22
DISCORD_TOKEN=
33
BOT_OWNER=
44
BOT_PREFIX=
5-
DB_CLIENT=
5+
DB_DRIVER=
6+
DB_HOST=db
7+
DB_PORT=
68
DB_NAME=
79
DB_USER=
810
DB_PASSWORD=

.gitignore

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
node_modules
2-
dist
1+
.idea/
2+
.vscode/
33
.env
4+
node_modules/
5+
dist
6+
pgdata
7+
tmp/
8+
temp/

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ FROM node:12.9-alpine
22

33
WORKDIR /usr/app
44

5-
COPY package.json .
5+
COPY package*.json ./
6+
COPY ormconfig.js ./
67

78
RUN apk update && apk upgrade && \
89
apk add --no-cache git
910

10-
RUN npm install
11+
RUN npm install --quiet
1112

1213
COPY . .

README.md

Whitespace-only changes.

docker-compose.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,28 @@ services:
88
- .:/usr/app/
99
- /usr/app/node_modules
1010
ports:
11-
- "3003:3003"
11+
- 3003:3003
12+
- 9229:9229
1213
depends_on:
13-
- postgres
14+
- db
15+
links:
16+
- db
1417
environment:
1518
NODE_ENV: ${NODE_ENV}
1619
DISCORD_TOKEN: ${DISCORD_TOKEN}
1720
BOT_OWNER: ${BOT_OWNER}
1821
BOT_PREFIX: ${BOT_PREFIX}
19-
DB_CLIENT: ${DB_CLIENT}
22+
DB_DRIVER: ${DB_DRIVER}
23+
DB_HOST: ${DB_HOST}
24+
DB_PORT: ${DB_PORT}
2025
DB_USER: ${DB_USER}
21-
DB_DB: ${DB_NAME}
2226
DB_PASSWORD: ${DB_PASSWORD}
23-
postgres:
27+
db:
2428
container_name: db
29+
volumes:
30+
- ./pgdata:/var/lib/postgresql/data
31+
ports:
32+
- 5432:5432
2533
image: postgres:11.5
2634
environment:
2735
POSTGRES_USER: ${DB_USER}

ormconfig.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require('dotenv').config();
2+
const { config } = require('./dist/config');
3+
4+
const {
5+
driver: type,
6+
name: database,
7+
user: username,
8+
host,
9+
password,
10+
port,
11+
} = config.db;
12+
13+
module.exports = {
14+
type,
15+
database,
16+
username,
17+
host,
18+
password,
19+
port,
20+
synchronize: true,
21+
logging: false,
22+
entities: [
23+
'dist/entity/**/*.js',
24+
],
25+
migrations: [
26+
'dist/migration/**/*.js',
27+
],
28+
subscribers: [
29+
'dist/subscriber/**/*.js',
30+
],
31+
cli: {
32+
entitiesDir: 'src/entity',
33+
migrationsDir: 'src/migration',
34+
subscribersDir: 'src/subscriber',
35+
},
36+
};

0 commit comments

Comments
 (0)