Trouble with setup

Im currently trying to deploy this repo right here with the following dockerfile: swisstackle/instagram_debater

FROM python:3.12.12 AS builder

ENV PYTHONUNBUFFERED=1 
PYTHONDONTWRITEBYTECODE=1
WORKDIR /app

RUN python -m venv .venv
COPY requirements.txt ./
RUN .venv/bin/pip install -r requirements.txt
FROM python:3.12.12-slim
WORKDIR /app
COPY --from=builder /app/.venv .venv/
COPY . .
CMD \[“sh”,“-c”,“if \[ "$PROCESS" = "dashboard" \]; then ./.venv/bin/uvicorn dashboard:app --host 0.0.0.0 --port 5000 --log-level info; elif \[ "$PROCESS" = "worker" \]; then ./.venv/bin/python main.py; else ./.venv/bin/python run_webhook.py; fi”\]

But for some reason the dashboard (python web server streaming a react site) does not load when I access the site.

One thing that I noticed was that the fly.toml does not look like it’s exposing anything meaningful:

app = "instagram-debater"
primary_region = "iad"

[http_service]
auto_start_machines = true
auto_stop_machines = true
force_https = true
internal_port = 8_080
min_machines_running = 0
processes = [ "app" ]

[[vm]]
cpu_kind = "shared"
cpus = 1
memory = "1gb"
memory_mb = 1_024

For example, how can I tie the dashboard python web server to an http service in there? How can I make sure that the other web server’s are exposed too?

Or is fly.io only suited for static sites without web server?

Hi… I don’t know the Python ecosystem that well, but it looks like you’re listening on port 5000, whereas internal_port is set to 8080.

[http_service] implicitly serves ports 80 and 443 to the outside world, so you should be ok there.

Also, it would probably be wise to move the long sh -c argument into a separate file, since it looks like you might have some glitches with quotation marks. (Or perhaps that’s the forum software mangling afterward, :sweat_smile:.)

Hope this helps!

1 Like

Is it possible to run two different webservers on one machine (One for port 8080 and the other one for port 8000)? Port 8000 doesn’t stream html, but is just a rest API.

It is possible, but it’s not the platform preference (so to speak). There’s some background on this in the following official doc:

https://fly.io/docs/app-guides/multiple-processes/

The above doesn’t emphasize it, but you would need to also add a [[services]] block to fly.toml, one with internal_port = 8000 and external ports disjoint from 80 and 443.

(E.g., choosing 8443 as the external HTTPS port for that second service.)

(Try to match the auto-start/auto-stop settings in both blocks, incidentally; it’s not clear what happens when they differ, :dragon:.)


Aside: If the dashboard is purely for personal use, then you might want to consider changing it to .internal-only. That gives (much) better security, and you can use flyctl proxy to tunnel through when you need access.

(You would need to listen on IPv6 for that, though.)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.