- Install NodeJS via
nvm
or any other way. - Install Yarn package manager
npm install --global yarn
- Run
yarn install
to install dependencies. - Copy google oauth2 secret keys:
- Go to https://console.cloud.google.com/apis/dashboard
- Go to side menu bar "Credentials"
- Select from "OAuth 2.0 Client IDs" your application or create those application credentials (use
REDIRECT_URL="/api/sessions/oauth/google"
) - Download credentials from the application page in "Additional information" (Client ID, Client secret e.t.c)
- Use credentials to fill in
${projectRootFolder}/server/.env.${process.env.NODE_ENV}
file.env.${process.env.NODE_ENV}
FILE:NODE_ENV=production # for prod GOOGLE_OAUTH2_CLIENT_ID="<USE YOUR CLIENT ID>" GOOGLE_OAUTH2_CLIENT_SECRET="<USE YOUR CLIENT SECRET>" GOOGLE_OAUTH2_REDIRECT_URL="http://localhost:8000/api/sessions/oauth/google" # <USE YOUR REDIRECT URL> GOOGLE_OAUTH2_TOKEN_URL="https://accounts.google.com/o/oauth2/token" GOOGLE_OAUTH2_USERINFO_URL="https://www.googleapis.com/oauth2/v1/userinfo" SQLITE_DATABASE_URL="file:./dev.db" ORIGIN='http://localhost:3000' PORT='8000' DOMAIN='localhost' ACCESS_TOKEN_TTL='15m' REFRESH_TOKEN_TTL='1y' RSA_PRIVATE_KEY="<GENERATED RSA PRIVATE>" RSA_PUBLIC_KEY="<GENERATED RSA PUBLIC>"
${projectRootFolder}/client/.env.${process.env.NODE_ENV}
FILE:VITE_GOOGLE_OAUTH2_URI="https://accounts.google.com/o/oauth2/v2/auth" VITE_GOOGLE_OAUTH2_CLIENT_ID="<USE YOUR CLIENT ID>" VITE_GOOGLE_OAUTH2_REDIRECT_URI="http://localhost:8000/api/sessions/oauth/google" # <USE YOUR REDIRECT URL> VITE_GOOGLE_OAUTH2_EMAIL_SCOPE="https://www.googleapis.com/auth/userinfo.email" VITE_GOOGLE_OAUTH2_PROFILE_SCOPE="https://www.googleapis.com/auth/userinfo.profile" VITE_SERVER_HOST_API="http://localhost:8000/api/"
- Run dev migrations with
yarn migration:dev
- Install recommended extensions in VS Code.
- Server:
yarn run dev
oryarn run dev:debug
for VS code launch debug. - Client:
yarn run dev
. - Linter helper commands:
- Server:
yarn prettier . --write
- Client:
yarn lint
,yarn prettier
- Server:
- Helper commands:
- Server DB client:
yarn prisma:cli
- development env CLI.
- Server DB client:
server
- server user
- Create user under root (switch on root -
sudo -s
):adduser server
- Give user SUDO permissions:
sudo usermod -aG sudo server
- Generate server SSH and add SSH Key to Github white list.
- Install Node and yarn.
- Pull files from GIT.
- Install NGINX -
sudo apt-get install nginx
- Run
yarn install
inclient
andserver
- Backend SERVER setup:
- Install PM2 (process manager):
npm install pm2 -g
oryarn global add pm2
- Build server:
yarn build
. Start PM2 process in/server
folder:pm2 start yarn --name server -- server
. Add ubuntu startup launcher:pm2 startup
- Setup DB:
yarn global add dotenv-cli
- Run first time -
yarn prisma:prod db push
- Install PM2 (process manager):
- Frontend client setup:
- Build
yarn build
- Build
- Final NGINX entry point setup:
$ cd /etc/nginx/ $ sudo cp nginx.conf nginx.conf.backup $ sudo nano nginx.conf $ cd ~/family_wishlist/client $ sudo rm -rf /usr/share/nginx/html/* $ sudo cp -r build/* /usr/share/nginx/html $ sudo service nginx restart
user server;
worker_processes auto;
events { worker_connections 1024; }
http {
server {
server_tokens off;
listen 2000;
root /usr/share/nginx/html;
include /etc/nginx/mime.types;
location /api {
proxy_pass http://localhost:2010;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location / {
try_files $uri $uri/ /index.html;
}
gzip on;
gzip_vary on;
gzip_http_version 1.0;
gzip_comp_level 5;
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 256;
gunzip on;
}
}