Skip to content

Commit 62999f0

Browse files
authored
Merge pull request #100 from VictorAugDB/update-docs-to-use-docker-compose-commands
Update docs to use docker compose commands
2 parents a7dd0a0 + 5b5c626 commit 62999f0

File tree

8 files changed

+86
-4
lines changed

8 files changed

+86
-4
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ dist/
33
.index/
44
*.log
55
.idea/
6-
.vscode/
7-
coverage/
6+
coverage/
7+
.vscode/*
8+
!.vscode/launch.json

.vscode/launch.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "attach",
10+
"name": "Docker: Attach to Node",
11+
"remoteRoot": "/api",
12+
"port": 9229,
13+
"skipFiles": [
14+
"<node_internals>/**"
15+
],
16+
"restart": true
17+
},
18+
{
19+
"name": "Attach Locally",
20+
"port": 9229,
21+
"request": "attach",
22+
"skipFiles": [
23+
"<node_internals>/**"
24+
],
25+
"type": "node",
26+
"restart": true
27+
}
28+
]
29+
}

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,29 @@ This version of the boilerplate is still in beta, so might contain abstractions
1010

1111
## How to run the server
1212

13+
### Requisites
14+
* To run the project wit Docker you need to have Docker installed in your computer: [Docker](https://docs.docker.com/engine/install/)
15+
* To run locally you need to have project dependencies installed globally in your machine
16+
1317
During development, the project can be run in two different ways.
1418

19+
### With Docker
20+
1521
If you want to just run the application in development mode, use the following command:
1622

23+
```sh
24+
$ docker compose up
25+
```
26+
27+
To run the application in debug mode in a way that the execution will stop when a debugger statement is called, use:
28+
29+
```sh
30+
$ docker-compose -f docker-compose.yaml -f docker-compose.debug.yaml up
31+
```
32+
33+
### Locally
34+
35+
If you want to just run the application in development mode, use the following command:
1736
```sh
1837
$ yarn dev
1938
```
@@ -44,9 +63,19 @@ $ yarn remote [server address] [REPL port]
4463

4564
## Tests
4665

47-
The boilerplate is prepared to run tests using Jest. We usually group the tests in folders called `__tests__` (following Jest convention) for each module of the application. To run the tests use the following command:
66+
The boilerplate is prepared to run tests using Jest. We usually group the tests in folders called `__tests__` (following Jest convention) for each module of the application. To run the tests use the following commands:
4867

68+
### With Docker
4969
```sh
70+
$ docker compose up
71+
72+
$ yarn test
73+
```
74+
75+
### Locally
76+
```sh
77+
$ yarn dev
78+
5079
$ yarn test
5180
```
5281

@@ -81,6 +110,17 @@ This boilerplate follows ideas from multiple good software development practices
81110

82111
To run your app in production mode, you'll need to follow these steps:
83112

113+
### With Docker
114+
115+
1. Define any environment variable important for production
116+
2. Go to `docker-compose.production.yaml` file, and add necessary configurations
117+
3. Run the following command:
118+
```sh
119+
$ docker-compose -f docker-compose.yaml -f docker-compose.production.yaml up
120+
```
121+
122+
### Locally
123+
84124
1. Build the application with `yarn build`
85125
2. Define any environment variable important for production
86126
3. Start the app with `yarn start`

docker-compose.debug.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
api:
3+
command: bash -c "yarn install && yarn debug"
4+
ports:
5+
- 9229:9229
6+

docker-compose.production.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
services:
2+
api:
3+
command: bash -c "yarn install && yarn build && yarn start"

docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
- .:/api
1313
ports:
1414
- 3000:3000
15+
- 2580:2580
1516
environment:
1617
HOST: 0.0.0.0
1718
DB_HOST: mongodb://node-api-boilerplate-mongodb:27017

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@
5858
},
5959
"scripts": {
6060
"prebuild": "rimraf dist",
61+
"start": "node . --transpile-only --files .| pino-pretty -c -l",
6162
"build": "tsc -p tsconfig.prod.json",
6263
"dev": "tsnd --transpile-only --files src/index.ts | pino-pretty -c -l",
63-
"debug": "tsnd --transpile-only --inspect --files src/index.ts | pino-pretty -c -l",
64+
"debug": "tsnd --transpile-only --inspect=0.0.0.0:9229 --nolazy --files src/index.ts | pino-pretty -c -l",
6465
"cli": "tsnd --transpile-only --files src/index.ts --cli",
6566
"remote": "ts-node bin/replClient.ts",
6667
"test": "jest"

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"outDir": "./dist",
99
"rootDir": "./src",
1010
"removeComments": false,
11+
"inlineSourceMap": true,
1112
"strict": true,
1213
"noImplicitAny": false,
1314
"noUnusedLocals": true,

0 commit comments

Comments
 (0)