- You can sign up for MongoDB Atlas and create an online database for free.
- Create a new account, accept, verify, login.
- Build a database
- Choose "FREE" tier
- Choose a provider and region. I chose AWS and Stockholm.
- Choose a cluster name. I chose
mern-typescript-deployment
. - Click "Create Cluster"
- Security Quickstart
- Authenticate your connection with
username
andpassword
- Choose a username and password
- Click "Create User"
- Where do you want to access your database from? I chose "Mylocal environment" and added my IP address. You can also add a whitelist for a specific IP address or a range of IP addresses.
- Click "Add My current IP Address"
- Finish and Close
- Authenticate your connection with
- Connect to mern-typescript-deployment and add connection string to .env
- You can sign up for Digital Ocean and create a virtual machine for free.
- Create Droplets
- Choose an image. I chose Ubuntu 22.04.
- Choose a plan. I chose Basic.
- Choose a size. I chose Premium Intel with NVMe SSD $21/month.
- Choose a datacenter region. I chose Frankfurt.
- Authentication: Choose a root password.
- Choose a hostname. I chose
mern-typescript-deployment
. - Click "Create Droplet"
- Open MobaXterm
- Click "Session"
- Click "SSH"
- Enter the IP address of your Digital Ocean Droplet
- Enter the username. I chose
root
. - Connect
- Enter the password you chose when creating the Droplet.
git clone https://github.com/deskavaenkelt/mern-typescript-deployment.git
- Open VSCode
- Click "Remote Explorer"
- Click "SSH Targets"
- Click "Add New SSH Host"
- Enter the IP address of your Digital Ocean Droplet
- Enter the username. I chose
root
. - Enter the password you chose when creating the Droplet.
- Click "Save"
- Click "Connect"
Add access to database from the droplets IP address
- Create and Edit environment variables in
.env
file - Edit row 11 in
mern-typescript-deployment/server_js/src/middlewares/Middleware.js
->const ALLOWED_ORIGINS = 'http://droplet-url'
- Edit row 15 in
mern-typescript-deployment/server_js/src/configuration/Configuration.js
->uri = 'mongodb+srv://'
- Create and Edit environment variables in
.env
file
- Make script run able with
chmod +x mern-typescript-deployment/scripts/*.sh
- Run install script for respective Client and Server
/var/www/html chmod +x scripts/install_client_full.sh chmod +x install_client_full.sh chmod +x uninstall_client_full.sh