Skip to content
This repository was archived by the owner on Mar 12, 2022. It is now read-only.

Commit 7c650c7

Browse files
committedJul 21, 2021
add docker-compose and isolate sensitive data
1 parent bfc2d33 commit 7c650c7

8 files changed

+95
-10
lines changed
 

‎.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
./node_modules
2+
./.git
3+
./dist
4+
**/*test*

‎.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
POSTGRES_USER= <<SEU USUARIO>>
2+
POSTGRES_PASSWORD= <<SUA SENHA SUPER ULTRA SECRETA>>
3+
POSTGRES_DB=aluraflix
4+
POSTGRES_PORT=5432

‎.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ lerna-debug.log*
3131
!.vscode/settings.json
3232
!.vscode/tasks.json
3333
!.vscode/launch.json
34-
!.vscode/extensions.json
34+
!.vscode/extensions.json
35+
36+
.env

‎docker-compose.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3.8'
2+
3+
services:
4+
db:
5+
container_name: aluraflix
6+
image: postgres:alpine
7+
restart: always
8+
env_file:
9+
- .env
10+
ports:
11+
- '5432:5432'
12+
pgadmin:
13+
container_name: pgadmin4_aluraflix
14+
image: dpage/pgadmin4
15+
restart: always
16+
environment:
17+
PGADMIN_DEFAULT_EMAIL: admin@admin.com
18+
PGADMIN_DEFAULT_PASSWORD: root
19+
ports:
20+
- '5050:80'

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@nestjs/common": "^7.6.15",
25+
"@nestjs/config": "^1.0.0",
2526
"@nestjs/core": "^7.6.15",
2627
"@nestjs/platform-express": "^7.6.15",
2728
"@nestjs/typeorm": "^8.0.1",

‎src/app.module.ts

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
import { Module } from '@nestjs/common';
2+
import { ConfigModule, ConfigService } from '@nestjs/config';
23
import { TypeOrmModule } from '@nestjs/typeorm';
4+
import { dbConfig } from './config/db.config';
35
import { VideosModule } from './videos/videos.module';
46

57
@Module({
68
imports: [
7-
TypeOrmModule.forRoot({
8-
type: 'postgres',
9-
host: 'localhost',
10-
port: 5432,
11-
username: 'root',
12-
password: 'root',
13-
database: 'aluraflix',
14-
autoLoadEntities: true,
15-
synchronize: true,
9+
ConfigModule.forRoot({
10+
isGlobal: true,
11+
load: [dbConfig],
12+
}),
13+
TypeOrmModule.forRootAsync({
14+
useFactory: (configService: ConfigService) => ({
15+
type: 'postgres',
16+
host: 'localhost',
17+
port: configService.get<number>('port'),
18+
username: configService.get<string>('pgUser'),
19+
password: configService.get<string>('pgPassword'),
20+
database: configService.get<string>('db'),
21+
autoLoadEntities: true,
22+
synchronize: true,
23+
}),
24+
inject: [ConfigService],
1625
}),
1726
VideosModule,
1827
],

‎src/config/db.config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const dbConfig = () => {
2+
return {
3+
pgUser: process.env.POSTGRES_USER,
4+
pgPassword: process.env.POSTGRES_PASSWORD,
5+
db: process.env.POSTGRES_DB,
6+
port: process.env.POSTGRES_PORT,
7+
};
8+
};

‎yarn.lock

+37
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,18 @@
616616
tslib "2.2.0"
617617
uuid "8.3.2"
618618

619+
"@nestjs/config@^1.0.0":
620+
version "1.0.0"
621+
resolved "https://registry.yarnpkg.com/@nestjs/config/-/config-1.0.0.tgz#966067195826b9b82b6fc63e990e31af28912185"
622+
integrity sha512-Id5dQsCISMxWu0oPKcEP4ltQ5Z6eY748WHIXNOFc2Q9qehvHVk8iMRMmTIzTJ+eCOB6qKBAdhTI4KuRyRlwAuQ==
623+
dependencies:
624+
dotenv "10.0.0"
625+
dotenv-expand "5.1.0"
626+
lodash.get "4.4.2"
627+
lodash.has "4.5.2"
628+
lodash.set "4.3.2"
629+
uuid "8.3.2"
630+
619631
"@nestjs/core@^7.6.15":
620632
version "7.6.18"
621633
resolved "https://registry.yarnpkg.com/@nestjs/core/-/core-7.6.18.tgz#36448f0ae7f7d08f032e1e7e53b4a4c82ae844d7"
@@ -2170,6 +2182,16 @@ domexception@^2.0.1:
21702182
dependencies:
21712183
webidl-conversions "^5.0.0"
21722184

2185+
dotenv-expand@5.1.0:
2186+
version "5.1.0"
2187+
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0"
2188+
integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==
2189+
2190+
dotenv@10.0.0:
2191+
version "10.0.0"
2192+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
2193+
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
2194+
21732195
dotenv@^8.2.0:
21742196
version "8.6.0"
21752197
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b"
@@ -3942,11 +3964,26 @@ lodash.clonedeep@^4.5.0:
39423964
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
39433965
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
39443966

3967+
lodash.get@4.4.2:
3968+
version "4.4.2"
3969+
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
3970+
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
3971+
3972+
lodash.has@4.5.2:
3973+
version "4.5.2"
3974+
resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862"
3975+
integrity sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=
3976+
39453977
lodash.merge@^4.6.2:
39463978
version "4.6.2"
39473979
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
39483980
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
39493981

3982+
lodash.set@4.3.2:
3983+
version "4.3.2"
3984+
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
3985+
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=
3986+
39503987
lodash.toarray@^4.4.0:
39513988
version "4.4.0"
39523989
resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561"

0 commit comments

Comments
 (0)
This repository has been archived.