Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2694b05

Browse files
author
Øivind Thorrud
committed
Added port env variable
1 parent 59779c9 commit 2694b05

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ FROM node:14.15.1-alpine3.12
22

33
WORKDIR /app
44

5-
COPY package*.json ./
5+
COPY . .
66

77
RUN yarn install --production
88

9-
COPY . .
10-
11-
RUN yarn tsc
9+
RUN yarn postinstall
1210

1311
EXPOSE 8080
1412

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ services:
1919
POSTGRES_USER: admin
2020
POSTGRES_PASSWORD: admin
2121
POSTGRES_DB: video
22+
PROD: 0
2223
ports:
2324
- "8080:8080"

index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const pgp = require('pg-promise')();
55
const cors = require('cors');
66
const bodyParser = require('body-parser');
77

8+
const port = process.env.PORT || 8080;
9+
810
const PG_USERNAME = process.env.POSTGRES_USER;
911
const PG_PASSWORD = process.env.POSTGRES_PASSWORD;
1012
const PG_DB = process.env.POSTGRES_DB;
@@ -116,8 +118,8 @@ app.route('/author/:id')
116118
res.send(data.name)
117119
})
118120
.catch(() => res.status(401).send);
119-
})
121+
});
120122

121-
server.listen(8080, () => {
122-
console.log('App is listening on port 8080');
123+
server.listen(port, () => {
124+
console.log(`App is listening on port ${port}`);
123125
});

0 commit comments

Comments
 (0)