Looking for guidance on deploying a SvelteKit app: https://kit.svelte.dev
Tried the normal node instructions, but keep getting errors:
“Failed due to unhealthy allocations”
Looking for guidance on deploying a SvelteKit app: https://kit.svelte.dev
Tried the normal node instructions, but keep getting errors:
“Failed due to unhealthy allocations”
If you run fly logs
after a failed SvelteKit deploy, you might be able to see why it isn’t working. “Unhealthy Allocations” either means the process crashed or health checks failed.
From that repository, I’m guessing it can’t figure out the start
command. How do you actually run a SvelteKit app? If you add a start
script in package.json
that runs what you want, it might work.
You need to add a start
to the package.json with the following command node build/index.js
. But do remember you will need some other steps before this to run the build command. I’m using a Dockerfile to action those steps first.
"scripts": {
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"preview": "svelte-kit preview",
"start": "node build/index.js"
}
and did you solve this?
I would be very interested to have such guide !
It would be pretty cool if there was a svelte-kit adapter like there is for Vercel. Might get a lot people here on fly.
If anyone builds one, I’m keen to hear about it.
I’m using a docker image to deploy my SvelteKit application with pnpm on Fly.io.
You can trigger the deploy with this command:
fly deploy --config fly.toml --dockerfile Dockerfile
And the Dockerfile
looks like this:
# This dockerfile must be built with the monorepo root directory as cwd
FROM node:lts-alpine
RUN npm i -g pnpm@latest
# all files needed for the build
COPY package.json .
COPY pnpm-lock.yaml .
COPY tsconfig.json .
COPY svelte.config.js .
COPY vite.config.ts .
# all folders needed for the build
COPY src src/
RUN pnpm install --frozen-lockfile
RUN pnpm build
EXPOSE 8080
CMD ["node", "build"]
Fly doesn’t really need an adapter in the way that vercel does, just building your app for node.js will work perfectly. Vercel needs it because of it’s own special APIs, but fly just runs linux vms.
If you want to get sveltekit going on fly, you just need a Dockerfile that runs npm run start
and you are set