Skip to content
This repository has been archived by the owner on Feb 14, 2022. It is now read-only.

Commit

Permalink
detail setup process
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekEagle committed Jun 7, 2021
1 parent f0f0c30 commit 1b59402
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 15 deletions.
15 changes: 10 additions & 5 deletions README.md
Expand Up @@ -2,21 +2,24 @@

## Project setup

```
```sh
npm install
```

## Requirements

- Latest Version of PostgreSQL
- Node.JS v14.13.1
- Node.JS v14.13.1 or later
- A machine to host on
- Nginx
- Write access to /etc/nginx/
- Write access to /var/

## .env File Configuration

The .env file stores the spooky scary sensitive data that you don't want people to see. The layout for the .env file is shown below

```
```env
SERVERIP={{database server ip}}
SERVERUSERNAME={{database username}}
SERVERPASSWORD={{database user password}}
Expand All @@ -25,14 +28,16 @@ SERVERDB={{the database to store the data in}}

## Debugging

If you want to debug the server, you can add `DEBUG=true` to the .env, or set the environment variable `DEBUG` to true.
Run the project in your debugger of choice, or start node with an inspection port open.

## Quick Start Guide

1. Clone this repository.
2. Run `npm install` and allow npm to install all packages.
3. Run `npm run build` and allow vue to build and compile the project to the `dist/` folder.
4. You can run `npm run serve-with-api` or run `node . 443`, keep in mind that both need permission to bind to ports below 1024, which usually means root/administrator permissions.
4. Run setup.sh in the root directory of the project to install and symlink everything in one command.
5. Setup database, create user and database specifically for cumulonimbus.
6. Start preview and API servers using `pm2 . --name api -i 2` and `pm2 ./thumbnailServer.js --name thumbnail -i 6`

## Online Demonstration

Expand Down
19 changes: 11 additions & 8 deletions nginx.conf
@@ -1,10 +1,11 @@
# Nginx Cumulonimbus Configuration
# DO NOT copy this file to sites-enabled in /etc/nginx symlink it so you don't have to copy it after every update.
log_format default '$http_x_forwarded_for - [$time_local] '
'$host "$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
client_max_body_size 100M;
access_log /home/alekeagle/sharex-vue/access.log default;
error_log /home/alekeagle/sharex-vue/error.log;
access_log /var/log/nginx/access.log default;
error_log /var/log/nginx/error.log;

upstream backend {
least_conn;
Expand All @@ -25,9 +26,10 @@ upstream preview {
server {
listen 443 ssl default_server http2;
server_name _;
root /home/alekeagle/sharex-vue;
ssl_certificate /home/alekeagle/sharex-vue/alekeagle.com.pem;
ssl_certificate_key /home/alekeagle/sharex-vue/alekeagle.com.priv.pem;
# /var/www-data should be symlinked to the root directory of this project.
root /var/www-data;
ssl_certificate /var/www-data/certs/public.pem;
ssl_certificate_key /var/www-data/certs/private.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
expires 30d;
add_header Cache-Control "public, no-transform";
Expand All @@ -41,7 +43,7 @@ server {
server {
listen 443 ssl http2;
server_name alekeagle.me localhost 192.168.*;
root /home/alekeagle/sharex-vue/dist/;
root /var/www-data/dist/;
expires 30d;
add_header Cache-Control "public, no-transform";
index /index.html;
Expand All @@ -59,7 +61,7 @@ server {
server {
listen 80 default_server;
server_name http.localhost;
root /home/alekeagle/sharex-vue/dist/;
root /var/www-data/dist/;
expires 30d;
add_header Cache-Control "public, no-transform";
index /index.html;
Expand Down Expand Up @@ -92,7 +94,8 @@ server {
server {
listen 443 ssl http2;
server_name docs.alekeagle.me docs.localhost;
root /home/alekeagle/sharex-vue-docs/src/.vuepress/dist/;
# if you plan on running the documentation along side the API, make sure /var/www-data-docs/ is symlinked to sharex-vue-docs-root/src/.vuepress/dist
root /var/www-data-docs/;
expires 30d;
add_header Cache-Control "public, no-transform";
index /index.html;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -7,8 +7,8 @@
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"serve-with-api": "node . 443",
"serve-with-api-dev": "DEBUG=\"true\" node . 3000"
"serve-with-api": "node .",
"thumb-server": "node thumbnailServer.js"
},
"dependencies": {
"bcrypt": "^5.0.1",
Expand Down
54 changes: 54 additions & 0 deletions setup.sh
@@ -0,0 +1,54 @@
#!/bin/bash
#This bash script is an automatic setup script that will automatically configure your server for Cumulonimbus.

if [[ $EUID > 0 ]]
then echo "Sorry! This script needs to be ran as root in order to fully setup Cumulonimbus!"
exit
fi

#Check for nginx
echo "Checking for nginx..."
dpkg -s nginx &> /dev/null
if [[ $? != 0 ]]; then
echo "nginx is not installed, installing it now..."
apt install nginx -y &> /dev/null
fi

echo "nginx installed."

echo "Checking for postgresql..."
dpkg -s postgresql &> /dev/null
if [[ $? != 0 ]]; then
echo "postgresql is not installed, adding repository, repository key, and installing..."
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' &> /dev/null
echo "Repository added, now adding repository key..."
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - &> /dev/null
echo "Key added, proceeding to install postgresql..."
apt update &> /dev/null
apt install postgresql -y &> /dev/null
fi

echo "postgresql installed."

echo "Checking for pm2..."
which pm2
if [[ $? != 0 ]]; then
echo "pm2 is not installed, installing..."
npm i -g pm2 &> /npm/null
fi

echo "pm2 installed."

echo "Removing default site from nginx and symlinking cumulonimbus.conf to /etc/nginx/sites-enabled/"
rm /etc/nginx/sites-enabled/default &> /dev/null
rm /etc/nginx/sites-enabled/cumulonimbus.conf &> /dev/null
ln -s $(pwd)/nginx.conf /etc/nginx/sites-enabled/cumulonimbus.conf &> /dev/null

echo "Added, now adding symlink for data for cumulonimbus website data."
rm /var/www-data &> /dev/null
ln -s $(pwd) /var/www-data &> /dev/null

echo "Finally, reloading nginx..."
nginx -s reload

echo "Done! All you have to do is run 'npm run build', setup the database, and you're ready to host!"

0 comments on commit 1b59402

Please sign in to comment.