Skip to content

Commit 62867b6

Browse files
committed
dockerized app
1 parent 485fd1b commit 62867b6

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ lerna-debug.log*
3333
!.vscode/tasks.json
3434
!.vscode/launch.json
3535
!.vscode/extensions.json
36-
/.env
36+
/.env*

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ WORKDIR /usr/src/app
44

55
COPY package*.json ./
66

7+
COPY entrypoint.sh ./
8+
79
RUN npm install
10+
RUN npm install -g db-migrate
11+
RUN npm install -g db-migrate-pg
812

913
COPY . .
1014

docker-compose.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,32 @@ services:
66
build: .
77
container_name: "tabbled-server"
88
restart: always
9-
command: npm run start:prod
9+
entrypoint: ["/bin/sh", "./entrypoint.sh"]
1010
ports:
1111
- "3000:3000"
12-
networks:
13-
- tabbled
1412
environment:
15-
- DB_HOST=host.docker.internal
16-
- DB_DATABASE=tabbled
13+
- DB_HOST=db
14+
- DB_PORT=5432
1715
extra_hosts:
1816
- "host.docker.internal:host-gateway"
17+
depends_on:
18+
- db
19+
20+
db:
21+
container_name: postgres
22+
image: postgres:12-alpine
23+
ports:
24+
- '5432'
25+
volumes:
26+
- pg_data:/data/db
27+
environment:
28+
- POSTGRES_PASSWORD=${DB_PASSWORD}
29+
- POSTGRES_USER=${DB_USER}
30+
- POSTGRES_DB=${DB_DATABASE}
31+
32+
volumes:
33+
pg_data:
34+
external: true
1935

2036

2137
networks:

entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
db-migrate up
3+
npm start

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { AppModule } from './app.module';
33
import * as process from "process";
44

55
async function bootstrap() {
6-
const app = await NestFactory.create(AppModule);
7-
await app.listen(process.env.PORT);
6+
const app = await NestFactory.create(AppModule);
7+
app.enableCors();
8+
await app.listen(process.env.PORT);
89
}
910
bootstrap();

0 commit comments

Comments
 (0)