Hey, I am trying to launch an app that has 3 separate processes:
- Front-end (Vite React)
- Back-end (ExpressJS)
- Database (Pocketbase)
I have made a working dockerfile that sets everything up correctly and manages these processes using supervisord. I understand that I need 3 different ports (I use 3000 for front-end, 3001 for back-end and 8090 for pocketbase). My initial efforts failed so I decided to take it one step at a time. First I successfully launched the front-end using this fly.toml setup:
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
Now when I visit https://<app_name>.fly.dev I get the visuals. Next I tried to launch my pocketbase database. I have added this code to fly.toml:
[[services]]
internal_port = 8090
protocol = "tcp"
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
[[services.ports]]
handlers = ["http", "tls"]
port = 8090
I launch the database with supervisord using the following line of code:
command=/app/pb/pocketbase serve --https=0.0.0.0:8090
Which I assume launches the database on the same app, but port 8090. So in my front-end code I use this to get the database object for later use:
import PocketBase from "pocketbase";
const pb = new PocketBase(`https://<app_name>.fly.dev:8090`);
export default pb;
However, when I use this, it gives me an error saying that “requested resource at https://<app_name>.fly.dev:8090/api/collections/users/auth-with-password does not exist”.
Am I doing something wrong with this set-up? Does the database not launch properly or am I messing up with the ports? I have read about using using [processes] in fly.toml to define different processes for different VMs, however, this will probably be more expensive, I would love to do this on a single VM.
Any help will be much appreciated, thanks!