Steps I always have to go through when setting up a new NodeJS/PostgreSQL back-end.
- Update Ubuntu:
sudo apt-get update. - Install node:
sudo apt install nodejs. Verify it worked with:node -v. - Install npm (node-package-manager):
sudo apt install npm. Verify withnpm -v. - Install n (version manager for node):
sudo npm i -g n. - Use 'n' to install the latest lts (long-term-support) version of node:
sudo n lts. - Restart the shell to switch to the latest version of node.
- Install ts-node to run development files:
sudo npm i -g ts-node. - Install typescript globally to build development files (with the tsc command):
sudo npm install -g typescript.
- Create a github account if you don't have one.
- Install/setup git:
sudo apt install gitgit config --global color.ui truegit config --global user.name "YOUR NAME"git config --global user.email "YOUR@EMAIL.com"ssh-keygen -t rsa -b 4096 -C "YOUR@EMAIL.com"(just hit enter at all the prompts)cat ~/.ssh/id_rsa.pub(copy the output)- Go to
https://github.com/settings/keys - Click on the "New SSH key" button in the top right
- Name it whatever you want.
- Paste the output from the
catcommand into the key text area. - Run
ssh -T git@github.com. Type yes at the prompt. - If if worked you should see:
- Hi excid3! You've successfully authenticated, but GitHub does not provide shell access.
- Clone the repo:
git clone git@github.com:seanpmaxwell/repo_name_here
- Run a git commit if you've made any changes to the repo. Must have clean working directory to run unlock.
- Install git-crypt:
sudo apt-get install -y git-crypt. - In the terminal, go into the project directory.
- To encrypt a file
-
- Make sure the file is specified under .gitattributes
-
- run
git-crypt init
- run
- To decrypt a file
-
- Get the gitcrypt key
devfrom someone. ONLY developers which handle deployment should haveprod.
- Get the gitcrypt key
-
- Place it under
.git/git-crypt/keys/. (may need to manually create the the parent dirs if they're not there)
- Place it under
-
- git-crypt unlock:
git-crypt unlock .git/git-crypt/keys/key_name_here.
- git-crypt unlock:
-
- To encrypt the files (maybe you need to test if your .gitattributes is working):
git-crypt lock
- To encrypt the files (maybe you need to test if your .gitattributes is working):
- Install postgresq.
sudo apt updatesudo apt install postgresql postgresql-contribsudo service postgresql start- To use postgres, we need a role and a database that matches the roles name:
sudo -u postgres createuser --interactive- If you get this error
could not change directory to "/home/user_name": Permission deniedthen you maybe need to runsudo chmod og+rX /home /home/user_name - Enter your linux user name:
- Enter 'y' for Shall the new role be a superuser?
- Create a new database for the superuser:
sudo -u postgres createdb "linux user name"- Create a password the new pg user:
sudo -u "linux user name" psql\password- Enter a password. DO NOT forget it.
\q