Deploy docker-compose to Fly.io

Hi all,
This is my current project structure:

root_folder
    backend
        ...
        Dockerfile
        entrypoint.sh
    frontend
        ...
        Dockerfile
    nginx
        Dockerfile
        default.conf
.env
docker-compose.yaml

docker-compose.yaml:

version: '3.7'

services:
  backend:
    volumes:
      - static:/static
    env_file:
      - .env
    build:
      context: ./backend
    ports:
      - "8000:8000"
  frontend:
    build:
      context: ./frontend
    volumes:
      - frontend:/app/build
  nginx:
    build:
      context: ./nginx
    volumes:
      - static:/static
      - frontend:/var/www/frontend
    ports:
      - "80:80"
    depends_on:
      - backend
      - frontend

volumes:
  static:
  frontend:

I tried to find some information online, but I haven’t been able to. Anyone that could help me?

Your not able to use docker compose.

Chances are, unless you nginx is doing something fancy or you need a feature of it for your purposes that Fly Proxy can’t handle, you can just use the built in Fly proxy.

The backend and frontend would be separate apps, most likely folders in the same repo, or separate repo each with their own fly.toml and Dockerfile.

You would configure and scale each independently.

There is a concept of process groups that you can look up, which lets you use one Dockerfile to deploy two separate apps with different port configurations. And many commands can target a individual process within a app. But this is typically used for more sidecar style applications, like Sidekick with Rails.

I use Docker Compose locally for testing, including mimicking some features of the fly proxy. When I deploy, I go into the folder in my monorepo of the app that I am trying to deploy.

I then run the fly command from that folder. The same Dockerfile used for Frontend or Backend, is also used for deploying to fly. I also use Nginix and Redis locally, but on fly.io, I use the built in proxy, and Upstash managed redis.

Good Luck!

Hope this helps.

1 Like

Thanks for the clarification!

I did the “backend and frontend as separate apps” approach and that works. However, my team wants to go with a hybrid approach: serve React build folder through Django’s static files.

Do you see this approach as possible? So far we only succeed to do it locally, but we haven’t been able to deploy it successfully in Fly.io.

I don’t know anything about Django, but I don’t see why it would not work.

Check that out. Fly maintains some good docks o. This specific topic, I bet there is even some sample repos.

Good Luck!

1 Like

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