Ah yes so what you have should work. Like I say, not sure why it seems to randomly fail.
However yes, the remote builder avoids having to use docker locally at all. For now remote builds are free (hopefully always will be!) so it’s worth seeing if it helps.
So yep, this would not be needed
- run:
name: Docker Build
command: docker build -t better-cart/<< parameters.fly_app_name >> -t registry.fly.io/<< parameters.fly_app_name >>:$CIRCLE_BUILD_NUM -f ./<< parameters.docker_path >> .
… because that is done by Fly, at their end.
And your deploy command would then be two lines, instead of four (one to install the Fly CLI, as you have got now, and then one to deploy). You would not need the middle two lines.
I don’t want to type an exact command because I don’t want to screw up your build as it’s more complicated than mine with params etc. But basically when you do
fly deploy --remote-only
… it will see you have a Dockerfile and so that will be used to do the remote build. I would remove the --detach maybe and so you’d see what it’s doing in realtime.
That assumes you have the Fly token in the envionment, else that would need passing in to the command too.
As regards the size, that makes less of an issue when doing a remote build but yes, small is always good. The first thing to look at would be the size of the base image. Instead of using a full ubuntu base you could use an alpine or slim image. Depends on your app, language etc, but I use nodejs and so use node slim as a base (because alpine has quirks with dns, but that’s another story).
There are lots of Dockerfile tricks like minimizing layers and using multi-stage builds which I’m no expert at as fortunately my Dockerfiles are super simple so I’ve never had to master them. But step one is getting it working at all, and then step two can be optimising