5 changed files with 85 additions and 3 deletions
@ -1 +1,9 @@
|
||||
Nothing to see here yet, folks. |
||||
Quarta tarefa: |
||||
|
||||
Faça com que o usuário e a senha do MongoDB seja passada para seu App utilizando variável de ambiente do Docker. |
||||
|
||||
Utilize um script bash para validar se as variáveis estão preenchidas antes de levantar o NodeJS. |
||||
|
||||
Mande foto do Dockerfile, código fonte e script bash. |
||||
|
||||
* passar usuário/senha por varíavel de ambiente docker (ENV). Usar bash para verificar se variável foi mesmo passada, se os campos de user/pass foram preenchidos. |
||||
|
||||
@ -0,0 +1,71 @@
|
||||
SUPER ONBOARD HELP CHEATSHEET |
||||
|
||||
PREPARING ENVIROMENT |
||||
|
||||
|
||||
// Simple way to connect to database |
||||
mongoose.connect(database).then( |
||||
() => {console.log('Database is connected') }, |
||||
err => { console.log('Can not connect to the database' +err) |
||||
}); |
||||
|
||||
npm :: config |
||||
// npm config set registry <registry url> |
||||
// using command line |
||||
npm config set registry http://npm.repo.labbs.com.br |
||||
// using .npmrc file |
||||
registry=http://npm.repo.labbs.com.br |
||||
|
||||
// Docker :: show container IP |
||||
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' [container_name] |
||||
|
||||
// Docker :: daemon config |
||||
// daemon file path |
||||
/etc/docker/daemon.json |
||||
// daemon file content |
||||
{ |
||||
"bip": "192.168.128.1/18", |
||||
"dns": ["172.18.51.10", "172.18.51.11"] |
||||
} |
||||
|
||||
// Docker :: send command line |
||||
docker exec -it [container_name] |
||||
|
||||
// Ubuntu :: reload daemon and start/restart/stop services |
||||
systemctl daemon-reload |
||||
systemctl restart docker |
||||
|
||||
// Ubuntu :: check service status |
||||
// all services |
||||
service --status-all |
||||
// one specific service |
||||
service docker status |
||||
|
||||
// MongoDB Access control |
||||
// connecting to mongo shell inside docker: |
||||
docker exec -it mongo mongo |
||||
// create admin user |
||||
use admin |
||||
db.createUser( |
||||
{ |
||||
user: "admin", |
||||
pwd: "admin", |
||||
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] |
||||
} |
||||
) |
||||
exit |
||||
// reconnect to mongo shell turning access control on |
||||
docker exec -it mongo mongo --auth |
||||
// create new user |
||||
use test |
||||
db.createUser( |
||||
{ |
||||
user: "myTester", |
||||
pwd: "test", |
||||
roles: [ { role: "readWrite", db: "test" }, |
||||
{ role: "read", db: "reporting" } ] |
||||
} |
||||
) |
||||
exit |
||||
// logging in as new user |
||||
mongo -u "myTester" -p "test" --authenticationDatabase "test" |
||||
Loading…
Reference in new issue