Skip to content

Commit a38133b

Browse files
committed
refactogin
Signed-off-by: Erick Wendel <erick.workspace@gmail.com>
1 parent 774e82d commit a38133b

File tree

5 files changed

+17
-67
lines changed

5 files changed

+17
-67
lines changed

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
FROM node:10-alpine
22

3-
RUN mkdir -p src/
3+
RUN mkdir -p /src
44

5-
COPY . src/
5+
COPY package.json src/package.json
6+
COPY package-lock.json src/package-lock.json
67

78
WORKDIR /src
89

9-
RUN npm i
10+
RUN npm install --only=production
11+
12+
COPY . /src
1013

1114
CMD npm start

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ docker run -d -p 5432:5432 --name postgres \
3434
docker run -p 3000:3000 \
3535
--link postgres:postgres \
3636
-e POSTGRES_HOST=postgres:mysecretpassword@postgres:5432 \
37+
-e POSTGRES_DB=heroes \
3738
erickwendel/nodejs-with-postgres-api-example:latest
3839
```
3940

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ const server = new Hapi.Server(
1919
);
2020
}
2121
const sequelize = new Sequelize(
22-
`postgres://${process.env.POSTGRES_HOST}/heroes`,
22+
`postgres://${process.env.POSTGRES_HOST}/${process.env.POSTGRES_DB || "heroes"}`,
23+
{
24+
ssl: process.env.POSTGRES_SSL,
25+
dialectOptions: {
26+
ssl: process.env.POSTGRES_SSL,
27+
},
28+
}
2329
);
2430
await sequelize.authenticate();
2531
console.log("postgres is running");

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
"joi": "14.3.1",
1717
"pg": "7.10.0",
1818
"pg-hstore": "2.3.2",
19+
"pm2": "3.5.0",
1920
"sequelize": "5.6.1",
20-
"vision": "5.4.4",
21-
"pm2": "^3.5.0"
21+
"vision": "5.4.4"
2222
},
23-
"devDependencies": {
24-
}
23+
"devDependencies": {}
2524
}

tsconfig.json

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)