statics, DNS issue, delivering file does not work

Trying to get a file like this: https://myproject.fly.dev/public/file.txt

Via flyctl ssh sftp shell I can check:

» ls app/public/
file.txt

/app is not a symlink, or at least that’s what I’m guessing.
In my Dockerfile I do this:

...
ADD . /app
WORKDIR /app
...

The fly.toml looks like this:

app = "myproject"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]

[experimental]
  auto_rollback = true

[[services]]
  processes = ["app"]

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls"]
    port = 443

[[statics]]
  guest_path = "/app/public"
  url_prefix = "/public"

It’s a python app without any webserver. In this case I just try to expose files statically within /app/public.

Currently I get this:

curl -i https://myproject.fly.dev/public/file.txt
curl: (6) Could not resolve host: myproject.fly.dev

This could be failing because statics need to exist in the Docker image. Perhaps, you could try using a python specific statics middleware, something like wsgi-static-middleware · PyPI to see if images are handled properly?

So static files need to exist in the docker image when the fly app is starting? They can’t be i.e. added while the app is running? I.e. download a file and move it into /public to make it (static) aviable to the public?

Edit:
Oh! :frowning:

These assets are extracted from your Docker image and delivered directly from our proxy on worker hosts.

you could try using a python specific statics middleware, something like wsgi-static-middleware · PyP

Thanks! GitHub - kobinpy/wsgi-static-middleware: WSGI Middleware for serving static files. seems outdated, but found this:
Serving JPG files via wsgiref.simple_server in Python 3 - "write() argument must be a bytes instance" - Stack Overflow

Trying this ““Hello World” WSGI” example now:

Removed the statics part from my toml and adjusted it like this:

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 8000

Should this work?
Expected a “hello world”, but getting the resolve issue

curl -i https://myproject.fly.dev # same for curl -i https://myproject.fly.dev:8000
curl: (6) Could not resolve host: myproject.fly.dev

Feels like I’m missing something else here. If this is runnign from the deployed Dockerfile do I need to define 8000 in there as well? Not too familiar with this.
Looking at this now: Troubleshooting your deployment · Fly Docs

Looks like I messed up ports and my app was also missing an ip v4 address.

After some back and forth it’s working. Thanks for the hint.

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