-
Notifications
You must be signed in to change notification settings - Fork 0
1 why
[ english ] [ spanish
]
Let's go to do this!
We are simulating that we repeatedly write these commands:
docker run --rm -it --name myProject-dev myProject-dev sh
...
docker run --rm -it --name myProject-prod myProject-prod sh
It will get more fun with the mapping:
docker run --rm -it -p 4200:4200 -p 49153:49153 -v /choclo:... --name myProject-dev myProject-dev sh
...
docker run --rm -it -p 4200:4200 -p 49153:49153 -v /choclo:... --name myProject-prod myProject-prod sh
For this, come to us scripts
npm in the package.json
! It should be something link this:
"runDev": "docker run --rm -it -p 4200:4200 -v /choclo:... --name myProject-dev myProject sh",
"runProd": "docker run --rm -it -p 4200:4200 -v /choclo:... --name myProject-dev myProject sh",
After that: npm run runDev
and npm run runProd
.
As we can see, there are "code" repeated, and if we multiply for each variable/environment, it can be lots of scripts with little differences, and so difficult to maintain. And we are so good developers and don't like to duplicate code (aren't you?)
We need to be more flexible and dynamic that allows us to scale more naturally. The approach chosen for this tool is templating.
Quick sample:
"project"="myProject"
"devName"="${project}-dev"
"prodName"="${project}-prod"
"dockerRun"="docker run --rm -it -p 4200:4200 -p 49153:49153 -v /choclo:... --name"
"runDev" =${dockerRun} ${devName} ${devName} sh
"runProd"=${dockerRun} ${prodName} ${prodName} sh
And it will run with: x runDev
and x runProd
.
Let us imagine that our team have the same configuration, quickly commands and standards, we will talk with the same language and we can feel as a home in front of other pc!
MIT © 2018 Crystian, made with love for you <3!