Hello,
Is there way to deploy app with docker-compose.yaml rather than Dockerfile?
Rgrds,
Bakyt
Not currently, unfortunately.
One approach is to make separate apps and then get them to communicate using the encrypted, private network (using .internal
hostnames) …
… or you would run multiple processes within one app. Then you would need an additional process in that app to keep them all running. For example using supervisor
. This page has some more details about that multi-process approach:
hey Greg,
thanks for ways out, but guess as a feedback, probably a nice feature to add, even if later on
cheers,
So I am trying also to get a multi machine setup working. Here is my issue.
I have two machines A and B
A needs to communicate with the public internet (https) and with B on a private network (http)
B needs to only communicate with A on a private network (http).
I have both machines registered in registry.fly.io
On local machine I use a docker compose. I use the machine name in my http calls in Machine A to call Machine B like http://machineb:8080
My question is how to setup my toml file ? Thanks!
Suggestion: next time, try creating a new topic, replying to an old topic (particularly one that has been solved) can easily be overlooked.
Let’s assume the following as a starting point:
app = "my-app"
primary_region = "iad"
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = false
auto_start_machines = true
min_machines_running = 1
processes = ["app"]
What that does is run one VM process named “app”, and makes it available via https on the public internet.
Next I’m going to assume that your Dockerfile builds all software needed to run both machines, the only difference is the CMD
used to start each machine. If that’s the case, you can add the following to your fly.toml
:
[processes]
app = "npm run start"
worker = "npm run worker"
Replace the npm
commands with the commands you use to start your processes. Each process will be run in a separate machine, or even set of machines if you like. Make sure that app
is the process that matches the http_service
in the fly.toml
.
Your Machine A can contact Machine B using the following DNS name:
worker.process.my-app.internal:8080
Where worker
is from the process
section and my-app
is the value listed as app =
at the top of the fly.toml
file.
So I had seen this toml config in the documentation. But my problem is I have two dockerfiles, each making a different “machine”. They are built seprately. one of my machines is python flask based and the other is nodejs based. are you suggesting one dockerfile with a layered build? Or can I have both machines deploy into the same fly app?
Two Dockerfiles would mean two images and two applications. Just put them in the same organization.
The first would have a [http_service]
in its fly.toml. The second would not.
The default process name is app
. Each of these machines can reference each other using the url pattern mentioned above. See also Private Networking · Fly Docs.
@thoughtsunificator It’s not immediately obvious (by the fact Fly supports Dockerfile
) but they don’t actually use Docker behind the scenes. So that’s why they don’t (and unfortunately can’t) support docker-compose
files.
I mean there must be a work around behind that to support docker-compose. Maybe the fly team needs to consider that.
You can run docker compose if you want, see Demo running docker compose up on fly machines
@rubys I do not quite get your example. How a simple docker-compose.yaml can fill into there? The following will create a "high availability" visitor counter app with postgresql and redis; as well as a stage app that runs everything in one machine under docker compose. · GitHub
That example takes advantage of the fact that the Rails dockerfile generator can also produce a docker-compose.yml file:
The key lines to run docker compose are here:
Also note that since docker compose up
takes a lot longer to start than starting a web server from a pre-built image, nginx is started to serve a “please wait” response untl the web server is ready, after which point it becomes a reverse proxy.
Try it. I’m not recommending it as an approach for everyone, but by seeing it it action you can see the advantages and disadvantages that approach has.