Failing to deploy nginx docker

Hello, I’m quite new to fly.io and still wondering the best ways to deploy my apps. I’m trying to deploy my “production” build of a React app, using nginx + docker. I was successful deploying my backend application just describing the Dockerfile and running ‘fly deploy’, but for some reason it doesn’t work for nginx application.

Here’s logging of the fly deploy:

DEBUG Loaded flyctl config from/home/ville/.fly/config.yml
DEBUG determined hostname: "ville-X1"
DEBUG determined working directory: "/home/ville/dev/kirvespeli-web"
DEBUG determined user home directory: "/home/ville"
DEBUG determined config directory: "/home/ville/.fly"
DEBUG ensured config directory exists.
DEBUG ensured config directory perms.
DEBUG cache loaded.
DEBUG config initialized.
DEBUG initialized task manager.
DEBUG skipped querying for new release
DEBUG client initialized.
DEBUG --> POST https://api.fly.io/graphql

{
  "query": "query ($appName: String!) { appbasic:app(name: $appName) { id name platformVersion organization { id slug } } }",
  "variables": {
    "appName": "kirvespeli-web"
  }
}

DEBUG {}
DEBUG <-- 200 https://api.fly.io/graphql (269.24ms)

{
  "data": {
    "appbasic": {
      "id": "kirvespeli-web",
      "name": "kirvespeli-web",
      "platformVersion": null,
      "organization": {
        "id": "ekQlpPKZYvQjGH4o4ge0Y82e0OhnlJ",
        "slug": "personal"
      }
    }
  }
}
DEBUG app config loaded from /home/ville/dev/kirvespeli-web/fly.toml
==> Verifying app config
--> Verified app config
==> Building image
DEBUG trying remote docker daemon
DEBUG Trying 'Buildpacks' strategy
DEBUG no buildpack builder configured, skipping
DEBUG result image:<nil> error:<nil>
DEBUG Trying 'Dockerfile' strategy
DEBUG --> POST https://api.fly.io/graphql

{
  "query": "mutation($input: EnsureMachineRemoteBuilderInput!) { ensureMachineRemoteBuilder(input: $input) { machine { id state ips { nodes { family kind ip } } }, app { name organization { id slug } } } }",
  "variables": {
    "input": {
      "appName": "kirvespeli-web",
      "organizationId": null
    }
  }
}

DEBUG {}
DEBUG <-- 200 https://api.fly.io/graphql (388.86ms)

{
  "data": {
    "ensureMachineRemoteBuilder": {
      "machine": {
        "id": "9080547f52e087",
        "state": "started",
        "ips": {
          "nodes": [
            {
              "family": "v6",
              "kind": "public",
              "ip": "2605:4c40:197:8ce3:0:ea89:f804:1"
            },
            {
              "family": "v4",
              "kind": "private",
              "ip": "172.19.17.106"
            },
            {
              "family": "v6",
              "kind": "privatenet",
              "ip": "fdaa:0:8936:a7b:caca:ea89:f804:2"
            }
          ]
        }
      },
      "app": {
        "name": "fly-builder-proud-dawn-7009",
        "organization": {
          "id": "ekQlpPKZYvQjGH4o4ge0Y82e0OhnlJ",
          "slug": "personal"
        }
      }
    }
  }
}
Waiting for remote builder fly-builder-proud-dawn-7009...
DEBUG checking ip &{Family:v6 Kind:public IP:2605:4c40:197:8ce3:0:ea89:f804:1 MaskSize:0}
DEBUG checking ip &{Family:v4 Kind:private IP:172.19.17.106 MaskSize:0}
DEBUG checking ip &{Family:v6 Kind:privatenet IP:fdaa:0:8936:a7b:caca:ea89:f804:2 MaskSize:0}
DEBUG --> POST https://api.fly.io/graphql

{
  "query": "query ($appName: String!) { appbasic:app(name: $appName) { id name platformVersion organization { id slug } } }",
  "variables": {
    "appName": "kirvespeli-web"
  }
}

DEBUG {}
DEBUG <-- 200 https://api.fly.io/graphql (198.54ms)

{
  "data": {
    "appbasic": {
      "id": "kirvespeli-web",
      "name": "kirvespeli-web",
      "platformVersion": null,
      "organization": {
        "id": "ekQlpPKZYvQjGH4o4ge0Y82e0OhnlJ",
        "slug": "personal"
      }
    }
  }
}
DEBUG --> POST https://api.fly.io/graphql

{
  "query": "mutation($input: ValidateWireGuardPeersInput!) { validateWireGuardPeers(input: $input) { invalidPeerIps } }",
  "variables": {
    "input": {
      "peerIps": [
        "fdaa:0:8936:a7b:8dd7:0:a:2"
      ]
    }
  }
}

DEBUG {}
DEBUG <-- 200 https://api.fly.io/graphql (202.52ms)

{
  "data": {
    "validateWireGuardPeers": {
      "invalidPeerIps": []
    }
  }
}
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder is ready to build!
Remote builder fly-builder-proud-dawn-7009 ready
==> Creating build context
--> Creating build context done
DEBUG fetching docker server info
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
DEBUG buildkitEnabled%!!(MISSING)(EXTRA bool=true)#1 [internal] load remote build context
Sending build context to Docker daemon  114.9MB

#1 DONE 12.9s

#1 [internal] load remote build context
#1 CACHED

#2 copy /context /
#2 CACHED

#3 [internal] load metadata for docker.io/library/nginx:1.22
#3 ERROR: unexpected status code [manifests 1.22]: 500 Internal Server Error
------
 > [internal] load metadata for docker.io/library/nginx:1.22:
------
DEBUG result image:<nil> error:error building: failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests 1.22]: 500 Internal Server Error
Error failed to fetch an image or build from source: error building: failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests 1.22]: 500 Internal Server Error

Just a quick note that building and running the docker locally works fine

In that case, you may try building the runc / docker image locally, instead:

flyctl deploy <args> --local-only

If not, and if it is okay, can you share your dockerfile?

With --local-only everything went well and it’s now deployed.

Dockerfile is pretty simple:

FROM nginx:1.22

COPY dist /usr/share/nginx/html

Is the COPY command causing issues when running deploy without --local-only?

From the logs, it seems the error in remote-builder (operated by Fly) happens when fetching the base nginx:1.22 image (and not when exec’ing COPY):

"[internal] load metadata for docker.io/library/nginx:1.22:"

"DEBUG result image:<nil> error:error building: failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests 1.22]: 500 Internal Server Error"

Up to Fly engineers to figure out why nginx:1.22 wouldn’t build. A short googling after, this stackoverflow answer seems to suggest that Docker BuildKit is at fault.

In the meanwhile, you may want to try whether nginx:1.22-alpine or nginx:1.23-alpine or nginx:latest works with the Fly’s (remote) builders.