Skip to content

Agouiscoding/CoinCome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy Instructions

If you have any deployment questions, or you need to upload your SSH keypair to the instance, please contact zg2921@nyu.edu.


Table of Contents


Overview

This document explains how to deploy the full CoinCome platform:

  • Backend (Spring Boot + MyBatis-Plus)
  • Frontend (Vue 3 + Vite + Nginx)
  • Database (OCI MySQL DB System)
  • Python scripts (via Java subprocess)
  • Local development workflow

Part 2: Deployment on Server

2a. Database Hosting (OCI MySQL)

The relational database is hosted on Oracle Cloud MySQL DB System.

  • Subnet: 10.0.1.0/24
  • DB private IP: 10.0.1.116
  • DB type: OCI MySQL 9.5
  • DB name: bitcome
  • Port: 3306 (only accessible inside subnet)

No public IP is assigned. The Spring Boot backend connects through environment variables:

DB_HOST     DB_PORT     DB_NAME
DB_USERNAME DB_PASSWORD

JDBC URL example:

jdbc:mysql://10.0.1.116:3306/bitcome

To access remotely (e.g., DataGrip), use SSH tunnel.


2b. Application Hosting (OCI Compute Instance)

Both backend and frontend are hosted on the same OCI compute instance:

Compute Instance

  • Private IP: 10.0.1.97
  • Public IP: 150.136.242.115
  • OS: Ubuntu 64-bit

Backend Stack

  • Java 17 (OpenJDK)
  • Spring Boot JAR (coincome.jar)
  • MyBatis-Plus
  • Python3 + pandas + requests
  • Systemd service (coincome.service)

Frontend Stack

  • Vue 3 + Vite
  • Built static files served by Nginx from /var/www/coincome
  • Nginx reverse proxy → Spring Boot (localhost:8080)

2c. Server Deployment Steps


Step 1: Build Backend & Frontend

1. Clone the repo

git clone https://github.com/Agouiscoding/CoinCome.git

2. Build backend

cd CoinCome/coincome
mvn clean package -DskipTests

3. Build frontend

Edit .env:

VITE_API_URL=https://150-136-242-115.sslip.io/api
VITE_GOOGLE_CLIENT_ID=xxxx.apps.googleusercontent.com
VITE_GOOGLE_REDIRECT_URI=https://150-136-242-115.sslip.io/auth/google/callback

Build:

npm install
npm run build

Step 2: Prepare Compute Instance

Install dependencies:

sudo apt update && sudo apt upgrade -y
sudo apt install -y openjdk-17-jre-headless python3 python3-pip nginx-core
pip3 install --no-cache-dir pandas requests

Setup swap (recommended for 1 GB RAM):

sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Step 3: Directory Layout & File Storage

Directory structure:

/opt/coincome/app/coincome.jar
/opt/coincome/uploads
/opt/coincome/python
/opt/coincome/tmp
/opt/coincome/logs
/var/www/coincome  ← frontend

Create them:

sudo mkdir -p /opt/coincome/{app,uploads,python,tmp,logs}
sudo mkdir -p /var/www/coincome
sudo chown -R ubuntu:ubuntu /opt/coincome /var/www/coincome

Step 4: Environment Variables & DB Config

Create:

/etc/coincome/coincome.env

Content:

SPRING_PROFILES_ACTIVE=prod

DB_HOST=10.0.1.116
DB_PORT=3306
DB_NAME=bitcome
DB_USERNAME=agou
DB_PASSWORD=<db-password>

FILE_UPLOAD_BASE_DIR=/opt/coincome/uploads
PYTHON_EXEC=/usr/bin/python3
PYTHON_SCRIPT_DIR=/opt/coincome/python
PYTHON_TMP_DIR=/opt/coincome/tmp

GOOGLE_CLIENT_ID=xxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=<google-client-secret>

APP_BASE_URL=https://150-136-242-115.sslip.io
OAUTH_REDIRECT_URI=https://150-136-242-115.sslip.io/api/auth/google/callback

Backend remote config (application_remote.yml) already supports ${VAR}.


Step 5: Run Spring Boot Backend

Upload JAR:

scp target/coincome-0.0.1-SNAPSHOT.jar \
    ubuntu@150.136.242.115:/opt/coincome/app/coincome.jar

Create systemd service:

/etc/systemd/system/coincome.service
[Unit]
Description=CoinCome Spring Boot Service
After=network.target

[Service]
User=ubuntu
WorkingDirectory=/opt/coincome/app
EnvironmentFile=/etc/coincome/coincome.env
ExecStart=/usr/bin/java -jar /opt/coincome/app/coincome.jar
Restart=always
RestartSec=5
SuccessExitStatus=143
StandardOutput=append:/opt/coincome/logs/coincome.out.log
StandardError=append:/opt/coincome/logs/coincome.err.log

[Install]
WantedBy=multi-user.target

Start:

sudo systemctl daemon-reload
sudo systemctl enable coincome
sudo systemctl start coincome
sudo systemctl status coincome

Step 6: Deploy Vue 3 Frontend with Nginx

Upload frontend:

scp -r dist/* ubuntu@150.136.242.115:/var/www/coincome/

Nginx config:

/etc/nginx/sites-available/coincome
server {
    listen 80 default_server;
    server_name 150-136-242-115.sslip.io _;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name 150-136-242-115.sslip.io _;

    root /var/www/coincome;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location /api/ {
        proxy_pass http://127.0.0.1:8080/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Enable config:

sudo ln -s /etc/nginx/sites-available/coincome /etc/nginx/sites-enabled/coincome
sudo nginx -t
sudo systemctl reload nginx

Step 7: Enable HTTPS (Let’s Encrypt)

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx \
  -d 150-136-242-115.sslip.io \
  --redirect --agree-tos -m you@example.com

Your site is now live at:

👉 https://150-136-242-115.sslip.io


Part 3: Local Development

3a. Access Remote MySQL via SSH Tunnel

ssh -i <your-private-key> \
    -L 3307:10.0.1.116:3306 \
    ubuntu@150.136.242.115

Use localhost:3307 in local backend.


3b. Run Spring Boot Locally

Check application.yml:

spring:
  datasource:
    url: jdbc:mysql://localhost:3307/bitcome?useSSL=false&allowLoadLocalInfile=true
    username: agou
    password: your-password

Run:

mvn build
mvn spring-boot:run

Environment variables needed:

GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=xxx

3c. Run Python Scripts Locally

Ensure python3 is installed:

python3 --version
pip3 install pandas requests

3d. Run Vue 3 Locally

.env:

VITE_API_URL=http://localhost:8080
VITE_GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com
VITE_GOOGLE_REDIRECT_URI=http://localhost:5173/auth/google/callback

Run:

npm install
npm run dev

Frontend: http://localhost:5173


3e. Full End-to-End Local Test

  1. Connect SSH tunnel (exposes DB at localhost:3307)
  2. Start backend on port 8080
  3. Start frontend on port 5173
  4. Add a folder upload/ under CoinCome/coincome

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors