ops Tutorial
Deploying Scala & React Apps to Shared Hosting
In this series
- •Deploying Expense Tracker to AWS
- •Deploying Expense Tracker to Google Cloud
- •Deploying Scala & React Apps to Shared Hosting
Shared hosting is a cost-effective way to host small applications. While it typically supports PHP/MySQL out of the box, deploying Java/Scala apps requires a bit more work (or a VPS).
Frontend Deployment
Deploying the React frontend is straightforward since it's just static files.
-
Build the project:
cd expense-tracker-ui npm run build -
Upload files: Copy the contents of the
distfolder to yourpublic_htmldirectory using FTP or a File Manager. -
Configure Routing: Create a
.htaccessfile to handle client-side routing:<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </IfModule>
Backend Deployment
For the Scala backend, you need a provider that supports Java or allows running long-lived processes (like a VPS). If you are on a strict shared host (cPanel), you might be limited.
-
Create a Distribution:
cd expense-tracker-api sbt dist -
Upload and Unzip: Upload the zip file from
target/universal/to your server and unzip it. -
Run the Application:
./bin/expense-tracker-api -Dplay.http.secret.key='production-secret' -Dhttp.port=9000 -
Reverse Proxy: Configure Apache/Nginx to forward requests from
api.yourdomain.comtolocalhost:9000.
Database
- Create a MySQL database via your hosting control panel.
- Update your
application.conf(or pass env vars) with the production credentials.
