To run the application locally for development purposes, please follow the instructions below:
- Development Setup: Deploy the application for local testing and development environment.
For running the application locally for production purposes, refer to the Production Setup.
To deploy both the frontend and backend for local, follow these steps:
Important
We are currently migrating from create-react-app to Nextjs in the frontend, if that's where you want to contribute, please check the following github issue here: #3
Before you begin, ensure that you have the following prerequisites in place:
- Node.js v16 or above
- Clone the project repository:
git clone https://github.com/devarshishimpi/staticstorm
cd staticstorm
- Navigate to the frontend directory:
cd frontend
- Install dependencies:
npm install
- Start the frontend development server:
npm start
The frontend should now be running locally, and you can access it in your web browser at http://localhost:3000
.
- Navigate to the server directory in a new terminal window:
cd server
- Install backend dependencies:
npm install
- Start the backend server:
node index.js
The backend should now be running locally, and you can access it in your web browser at http://localhost:8181
.
To deploy both the frontend and backend to proudction, follow these steps:
Before you begin, ensure that you have the following prerequisites in place:
- Linux Machine (eg: Ubuntu)
- Nodejs v16 or above
- Nginx Server
- Clone the project repository:
git clone https://github.com/devarshishimpi/staticstorm
cd staticstorm
- Navigate to the frontend directory:
cd frontend
- Install dependencies:
npm install
- Build the frontend:
npm run build
- Copy the frontend files to the server's HTML directory:
sudo cp -rf build /var/www/html
- Navigate to the server directory:
cd ../server
- Install backend dependencies:
npm install
- Copy the backend files to the server's HTML directory:
sudo cp -rf . /var/www/html
- Edit the Nginx configuration file:
sudo vim /etc/nginx/sites-available/default
- Update the Nginx configuration to include both frontend and backend as separate locations:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/build;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://localhost:8181;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
autoindex off;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 7d; # Cache these static assets for 7 days (adjust as needed)
add_header Cache-Control "public, max-age=604800, immutable";
}
}
- Restart Nginx to apply the configuration changes:
sudo service nginx restart
Note
If you want to use your custom domain name and subdomain, replace the second _
in server_name _;
with your domain name and subdomain.
- Access Your Application
You can now access your application in a web browser by navigating to http://youripaddress
. The frontend will be served from the root, and the backend API will be available at http://youripaddress/api
.