Coder Social home page Coder Social logo

ansible-course-capstone-project's Introduction

Databasee

Install:

Install MongoDB

# Ubuntu 18.04 LTS
sudo apt-get install gnupg

wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -

echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | sudo tee /etc/apt/sources.list.d/mongodb.list


sudo apt install mongodb-org

sudo systemctl enable mongod
sudo systemctl start mongod 

# whitelist IPs : https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-18-04

# Validate: mongo --eval 'db.runCommand({ connectionStatus: 1})'

Configure DB

Admin config

#1) disable security (/etc/mongod.conf) --> Restart Mongodb
#> security:
#>   authorization: "disabled"

#2) drop admin user if exist
mongo admin --eval 'db.dropUser("superadmin")'
#3) create admin user
mongo admin --eval 'db.createUser( { user: "superadmin", pwd: "MyPass1234", roles: [ { role: "clusterAdmin", db: "admin" }, { role: "userAdminAnyDatabase", db: "admin" } ] } )'
#4) enable security (/etc/mongod.conf) --> Restart Mongodb
#> security:
#>   authorization: "enabled"

App user config

mongo admin --eval 'db.createUser( { user: "todo", pwd: "todo", roles: [ { role: "readWrite", db: "test" } ] } )'

Network config

  • Replace the value of bindIp in /etc/mongod.conf
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mongod.conf

Backend

Prebuild:

  • Install go

Build

  • Checkout source code
  • Run go build

Run Manually

Check connectivity with DB

nc -zv <db-hostname> 27017

From source code

export DB_CONNECTION=mongodb://user:pass@localhost:27017 \
       DB_NAME=test
go run main.go

Or From build artifact

export DB_CONNECTION=mongodb://user:pass@localhost:27017 \
       DB_NAME=test
/artifact-build-file

Run Production grade

1 - Create Systemd Service Todo which populates (2) & manages (3) -> notify: systemctl reload-daemon

2 - Put env vars in seperated file ( /etc/todo.env)

3 - Move build file from /tmp/todo to a standard place (/usr/local/bin/todo) -> notify: systemctl restart todo

Deploy

  • systemd service

Frontend

Prebuild:

  • Install nodejs

Build

  • Checkout source code
  • Run npm install

Run Manually

# Set REACT_APP_API_ENDPOINT, then
npm start

Run Production grade

npm install pm2 -g
# Set REACT_APP_API_ENDPOINT, then
# Start App with pm2
pm2 start node_modules/react-scripts/scripts/start.js --name todo

ansible-course-capstone-project's People

Contributors

abdennour avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.