You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ If you want to just run the application in development mode, use the following c
16
16
17
17
```sh
18
18
$ yarn dev
19
+
19
20
```
20
21
21
22
To run the application in debug mode in a way that the execution will stop when a debugger statement is called, use:
@@ -50,6 +51,68 @@ The boilerplate is prepared to run tests using Jest. We usually group the tests
50
51
$ yarn test
51
52
```
52
53
54
+
## Docker wrapper
55
+
56
+
In case you want to use Docker to run it, this project includes a [docker wrapper](https://github.com/brunohcastro/node-base) for development. Any command can be executed by calling the scripts under the `dbin/` folder.
57
+
58
+
```sh
59
+
$ dbin/yarn dev
60
+
61
+
$ dbin/yarn debug
62
+
63
+
$ dbin/yarn cli
64
+
65
+
$ dbin/yarn remote [server address] [REPL port]
66
+
67
+
$ dbin/yarn test
68
+
```
69
+
70
+
The container runs using host networking, so there's no need to map ports. Keep in mind that environment variables should be added to the docker-compose.yml.
71
+
72
+
### Wrapper commands
73
+
74
+
```sh
75
+
# Runs the command inside an ephemeral container using the app service described in the docker-compose file as a base (use the --root flag if the command should be run as root)
76
+
$ dbin/run [--root] <command>
77
+
78
+
# Rebuild the image after any changes to the dockerfile
79
+
$ dbin/build
80
+
81
+
# Remove all containers and their volumes (WARNING any cache or files not stored in the filesystem will be deleted)
82
+
$ dbin/dispose
83
+
84
+
# Appends a RUN command to the base image, useful to install new packages
85
+
$ dbin/chimg <command>
86
+
```
87
+
88
+
### Wrapper Aliases
89
+
90
+
```sh
91
+
# Creates a new <name> file in dbin to alias the <command> inside the docker container (use the --root flag if the command should be run as root)
92
+
$ dbin/mkalias [--root] <name><command>
93
+
94
+
# Opens a new terminal in the project folder (use the --root flag if the shell should assume the root user)
95
+
$ dbin/shell [--root]
96
+
97
+
# Runs npm in the project folder
98
+
$ dbin/npm
99
+
100
+
# Runs npx in the project folder
101
+
$ dbin/npx
102
+
103
+
# Runs yarn in the project folder
104
+
$ dbin/yarn
105
+
```
106
+
107
+
### Wrapper Helpers
108
+
109
+
```bash
110
+
# Adds dbin folder to the PATH only for the current terminal session.
111
+
$ source dbin/local-env
112
+
113
+
# After using this command you can use the any script inside the dbin folder without the dbin/ prefix
114
+
```
115
+
53
116
## Dependency injection
54
117
55
118
We use [Awilix](https://www.npmjs.com/package/awilix) to implement dependency injection and decouple the parts of your application. The boilerplate was developed in a way that each [module](#modules) is able to consume and augment the registered dependencies separately. Click here to know more about [inversion of control and dependency injection](https://www.martinfowler.com/articles/injection.html). The creator of Awilix also has a very good series of posts about the design decisions of the library that you can read [clicking here](https://medium.com/@Jeffijoe/dependency-injection-in-node-js-2016-edition-f2a88efdd427).
0 commit comments