How can I get one image to inherit from another remotely?

I have two images inside an app. They are like so, with one inheriting from the other:

  1. sequoia-browser-small, parent = FROM node:22-bookworm-slim
  2. sequoia-browser-large, parent = FROM sequoia-browser-small

These build fine in Docker locally.

I have a little creation script for Fly:

#!/bin/bash

createMachine () {
  NAME=$1
  DOCKER_PATH=$2
  MEMORY=$3
  flyctl machine create \
      . \
      --config machines/fly.toml \
      --region lhr \
      --org Personal \
      --vm-memory $MEMORY \
      --dockerfile $DOCKER_PATH \
      --name $NAME
}

createMachine "sequoia-browser-small" "machines/small/Dockerfile" "256M"
createMachine "sequoia-browser-large" "machines/large/Dockerfile" "1024M"

However the second one does not work, because the local image FROM name sequoia-browser-small is not specific enough. I could change it in the Dockerfile to registry.fly.io/sequoia-browser-test:deployment-xxx but then local builds would fail.

I guess I could rename my local build output to match the remote. However, I would need Fly not to dynamically name the image; is there a machine create switch for that?

For now, I have found --build-local-only, which seems to work. It’s a bit slower due to needing to send the image over a slow internet connection, but that’s not a major bother. As an aside, I found that switch documented on the web, and it seems it is not detailed in flyctl machine create --help. Is this an oversight, or is the switch deprecated?

1 Like

Hm… The source code deliberately has it set to Hidden, but as far as I know that doesn’t imply deprecation.

Yep, --image-label, which is… also hidden, :sweat_smile:.

flag.String{
  Name:        "image-label",
  Description: "Image label to use when tagging and pushing to the fly registry. Defaults to \"deployment-{timestamp}\".",
  Hidden:      true,
}

I tried a test build with fly deploy --build-only --push --image-label=semi, and it came out as registry.fly.io/<app-name>:semi. (No 01JW<long-string> timestamp at the end.)

It looks like fly m create would work the same, but if not, then you could fall back to the new blueprint’s approach of having a separate app that exists solely to build (and then hold) the browser-small image…

Possibly I’m misunderstanding this part, since I don’t use the Docker CLI myself, but could you use an ARG for this?

Have it default to the local name but then override it in fly.toml.

I’ve used the following closely related structure in the past…

ARG DEBIAN=debian:bullseye-slim

FROM ${DEBIAN}
[build.args]
  DEBIAN = "debian:bookworm-slim"

Anyway, hope some non-empty subset of this helps!

Ah super, thanks @mayailurus :folded_hands:. I’ve not ever used build args in the FROM before, but that makes sense. Combining that with --image-label sounds like it should work; I will give it a go.

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