Docker-compose.yml to fly.toml

Hi! I’m a beginner and not so technical.
I thought it should be easy to deploy a Docker stack but I’m seeing it’s difficult.
I thought Fly would fetch my Dockerfile, dotenv and Docker-compose.yml and build it all from there. Then I realized you should built it from the toml file.
Looks like Fly isn’t following the base Docker stack files, so not easy to setup. My stack has 4 images that work together but I don’t know how to set it up properly.
In a regular VPS I Docker compose up and it works out of the box. I want to learn how to set up here.

It’s a complex compose.

services:
  api:
    container_name: 
    ports:
      - "${PORT}:${PORT}"
    depends_on:
      - mongodb
      - rag_api
    image: ghcr.io/.../dev:latest
    restart: always
    user: "${UID}:${GID}"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      - HOST=0.0.0.0
      - MONGO_URI=mongodb://mongodb:27017/
      - MEILI_HOST=http://meilisearch:7700
      - RAG_PORT=${RAG_PORT:-8000}
      - RAG_API_URL=http://rag_api:${RAG_PORT:-8000}
    volumes:
      - type: bind
        source: ./.env
        target: /app/.env
      - ./images:/app/client/public/images
      - ./logs:/app/api/logs
  mongodb:
    container_name: mongodb
    image: mongo
    restart: always
    user: "${UID}:${GID}"
    volumes:
      - ./data-node:/data/db
    command: mongod --noauth
  meilisearch:
    container_name: meilisearch
    image: getmeili/meilisearch:v1.7.3
    restart: always
    user: "${UID}:${GID}"
    environment:
      - MEILI_HOST=http://meilisearch:7700
      - MEILI_NO_ANALYTICS=true
    volumes:
      - ./meili_data_v1.7:/meili_data
  vectordb:
    image: ankane/pgvector:latest
    environment:
      POSTGRES_DB: mydatabase
      POSTGRES_USER: myuser
      POSTGRES_PASSWORD: mypassword
    restart: always
    volumes:
      - pgdata2:/var/lib/postgresql/data
  rag_api:
    image: ghcr.io/..../dev-lite:latest
    environment:
      - DB_HOST=vectordb
      - RAG_PORT=${RAG_PORT:-8000}
    restart: always
    depends_on:
      - vectordb
    env_file:
      - .env

volumes:
  pgdata2:

And another one for the RAG:

services:
  vectordb:
    image: ankane/pgvector:latest
    environment:
      POSTGRES_DB: mydatabase
      POSTGRES_USER: myuser
      POSTGRES_PASSWORD: mypassword
    volumes:
      - pgdata2:/var/lib/postgresql/data
    ports:
      - "5433:5432"

  rag_api:
    image: ghcr.io/.../dev:latest
    environment:
      - DB_HOST=vectordb
      - DB_PORT=5432
      - POSTGRES_DB=mydatabase
      - POSTGRES_USER=myuser
      - POSTGRES_PASSWORD=mypassword
    ports:
      - "${RAG_PORT}:${RAG_PORT}"
    depends_on:
      - vectordb
    env_file:
      - .env

volumes:
  pgdata2:

Yet sometimes I use also the compose override to adjusts some settings.
Thanks

if you were setting this up to run at scale you’d want a different app for each entry in your compose file (an app for API, one for mongo, one for mellisearch, one for postgres and one for your RAG). or you could use SaaS offerings for postgres and mongo if you didn’t want to run them yourself (you might be able to find someone running mellisearch).

it’s not clear from your two compose files while there’s rag_api and postgres twice, that seems like it might be an error?

also, unrelated, but I’m definitely curious why mongo, mellisearch, and postgres are getting used, there’s a not-insignificant overlap between those three tools

I see what you say about one app for each entry. Based on that I’m wondering, wouldn’t that more difficult to set and more expansive than deploying composing it up at any regular VPS or even Railway or Render. I’m new to Fly.io and not advanced technically. I just want to deploy a compose Docker app for low cost in the beginning and be able to scale it up with great performance in the near future.

I think Render would be a similar experience to fly, there’d be a translation step you’d need to do to spin up the various containers vs using your existing docker-compose file.

you can run docker and docker-compose in a fly vm (see this comment about running docker in firecracker) but i don’t know what hiccups you’ll run into, and it’s doing things the hard way (I know that seems a little counter-intuitive) the approach there would be that you’d install docker and docker-compose into your Dockerfile and whatever else was needed to use docker. then your CMD (or entrypoint) would be a docker-compose up command. ideally your image build would download the correct images for all of your dependencies but i’m not sure what issues you’d run into doing that.

stepping back for a moment, if I were approaching this as you (I’m making some assumptions) I would look into hosted versions of postgres, mongo, and meilisearch when running these in production.

your expertise isn’t in running these services and while fly has good high availability configs for postgres it takes some expertise to run at scale (and if you look through the forums you’ll see there’s a big of an expectation mismatch from people thinking the high-availability fly postgres configs are the same as something like Supabase, Heroku Postgres, RDS, or Digital Ocean’s managed Postgres).

supabase has a postgres available with fly Supabase Postgres · Fly Docs

talking about price, running each of those services on fly as separate apps is going to be more expensive than a $4/mo digital ocean droplet (though it’s possible to run them with docker-compose). the droplet will be pretty easy to get docker-compose setup. that said, “RAG” is one of the services you’re talking about and if you’re generating vector embeddings on the host, a $4 droplet isn’t going to cut it (neither with a shared-1x cpu machine from fly).

at some point you’ll want these all as separately managed services (perhaps not right now) and when that happens i’d expect fly to be compelling on price and developer experience. the question is whether you’d want to spend that effort to split things up now or later

1 Like

Thank you very much for your response.
I’m trying to deploy an application that is already fully packaged in Docker.
Nowadays, almost everything is in Docker.
I, in my naivety, thought using fly would be as simple as it seems on the website and in the docs. I like the philosophy of fly; it seems they’re offering something unique, but far from simple. I assume that fly has users with various levels of technical knowledge. Still, I find the documentation insufficient. Also, the forum here isn’t very active. You can see that only one person has responded to me.
However, I’ll follow your instructions and try to deploy here.

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