SvelteKit support

New with Flyctl v0.2.33 / @flydotio/dockerfile v0.5.5: SvelteKit support.

This was an easy win: unlike other frameworks that add a start script, SvelteKit requires you to “know” that the start command is ./build/index.js. As computers are good at if checks, swapping out the CMD in the Dockerfile if @sveltejs/kit is found in the devDependencies in the package.json takes care of this chore.

One other small detail that applies to those of you using bun, adding --bun on the RUN bun --bun run build step enables the bulid to complete without installing node. This change was made in a framework independent way, so it applies to all JS frameworks whose build steps involve running a script that starts with #!/usr/bin/env node.

As always, please try it out and let us know if there is more ways in which we can make it easier to launch applications using your favorite framework!

3 Likes

FYI, I tried following the steps in Run a SvelteKit App · Fly Docs to deploy a SvelteKit app (specifically, SvelteKit’s demo app), but the deployment failed with this error:

ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/app/package.json'

I looked at the Dockerfile created by flyctl launch and saw this command:

COPY --from=build /app/build /app/build

Since the error was caused by a missing /app/package.json, I changed the command to:

COPY --from=build /app /app

After this change, the deployment succeeded, and the app is now running at: https://my-hello-sveltekit.fly.dev/

So it appears this is a bug in the Dockerfile generated by flyctl?

Yup, a bug. Would the following work for you?

The idea here is to reduce image size by only including the built application.

1 Like

That worked. Thanks!

Cool. Released as @flydotio/dockerfile - npm 0.5.7