Configuring port for LiteFS setup

I am trying to setup litefs with my app and am running into an issue after setting it up. Once I add the setup to my docker config I start getting the below message on deploy:


WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
  - 0.0.0.0:8081
Found these processes inside the machine with open listening sockets:
  PROCESS        | ADDRESSES                              
-----------------*----------------------------------------
  litefs mount   | [::]:20202                             
  /.fly/hallpass | [fdaa:3:57fa:a7b:9adb:5b31:85db:2]:22  

I am assuming that I need it to be on the port my app is being served over, but im not sure what to configure to get there. Below are my fly.toml, docker file, and litefs.yml

fly.toml

# fly.toml app configuration file generated for bumper-shopify on 2023-10-20T12:06:58-07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "bumper-shopify"
primary_region = "ord"

[build]

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

[env]
PORT = "8081"
SHOPIFY_APP_URL = "https://xxxxxx.fly.dev"
SHOPIFY_API_KEY = "XXXXXXXXXXXXXXXXX"
SCOPES = "write_products,write_metaobject_definitions,write_metaobjects"

[mounts]
  source="data"
  destination="/data"

Docker file

FROM node:18-alpine

EXPOSE 8081
WORKDIR /app
COPY . .

RUN npm install
RUN npm run build

# packages 
RUN apk update && apk upgrade
# for alpine-based images
RUN apk add ca-certificates fuse3 sqlite
COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs

ADD ./litefs.yml /tmp/litefs.yml
ADD /prisma/dev.sqlite /tmp/db.sqlite

RUN cp /tmp/litefs.yml /etc/litefs.yml

ENTRYPOINT litefs mount

CMD ["npm", "run", "start"]

litefs.yaml

# note: there should be one template for this, which you can update as necessary.
# note: had to leave the getting started guide and go to the lease management section bc not using fly
# note: lease.hostname and lease.advertise-url are not clear
# note: we should have an example docker-compose setup with everything working both with consul
# and static leases
# This directory is where your application will access the database.
fuse:
  dir: "/litefs"

# This directory is where LiteFS will store internal data.
# You must place this directory on a persistent volume.
data:
  dir: "/data"

# The lease section defines how LiteFS creates a cluster and
# implements leader election. For dynamic clusters, use the
# "consul". This allows the primary to change automatically when
# the current primary goes down. For a simpler setup, use
# "static" which assigns a single node to be the primary and does
# not failover.
lease:
  # Required. Must be either "consul" or "static".
  type: "static"

  # Required. The URL for this node's LiteFS API.
  # Should match HTTP port.
  advertise-url: "http://$HOSTNAME:8081"

  # Specifies whether the node can become the primary. If using
  # "static" leasing, this should be set to true on the primary
  # and false on the replicas.
  candidate: $IS_PRIMARY

If you are wanting to use the LiteFS proxy on port 8080, you’ll need to add a section for it in the litefs.yml config. You can find the docs for that section here: LiteFS Config Reference · Fly Docs

Also, the advertise URL should point to LiteFS’ internal port (20202) and should be accessible from other nodes. On Fly.io, that looks like:

proxy:
  advertise-url: "http://${FLY_ALLOC_ID}.vm.${FLY_APP_NAME}.internal:20202"

Thanks Ben, but I’m trying to do the static lease not consule. I followed the steps in the docker Getting Started with LiteFS in Docker · Fly Docs

They say to:

lease:
  # Required. Must be either "consul" or "static".
  type: "static"

  # Required. The URL for the primary node's LiteFS API.
  # Note: replace `primary` with the appropriate hostname for your primary node!
  advertise-url: "http://primary:20202"

  # Specifies whether the node can become the primary. If using
  # "static" leasing, this should be set to true on the primary
  # and false on the replicas.
  # Note: update this to `false` on the replica nodes!
  candidate: true

I have tried the proxy option and am still just getting the same error. Can you or anyone share a setup that works?

We have some separate docs for getting started on Fly.io that might work better: Getting Started with LiteFS on Fly.io · Fly Docs

Thanks ben, but this document relates to the consul lease and not the static lease. It also is not the docker documentation which is what I am using. If you don’t know the answer that’s fine, ill ask elsewhere.