Svelte Kit & LiteFS application not reachable by proxy

Hi there!

First time Fly user here, loving the platform so far but I’m having an issue when trying to deploy Svelte Kit with LiteFS. Svelte Kit only works fine, but when I try to set up LiteFS I get an “Application is not reachable at error”. I followed the official guide and used some other Node.js applications as an example, but no dice.

This is my Fly file:

# See for information about how to use this file.

app = 'my-app'
primary_region = 'cdg'


  source = 'litefs'
  destination = '/data'

  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1

This is my LiteFS configuration file:

# The fuse section describes settings for the FUSE file system. This file system
# is used as a thin layer between the SQLite client in your application and the
# storage on disk. It intercepts disk writes to determine transaction boundaries
# so that those transactions can be saved and shipped to replicas.
  dir: "/litefs"

# The data section describes settings for the internal LiteFS storage. We'll
# mount a volume to the data directory so it can be persisted across restarts.
# However, this data should not be accessed directly by the user application.
  dir: "/var/lib/litefs"

# This flag ensure that LiteFS continues to run if there is an issue on starup.
# It makes it easy to ssh in and debug any issues you might be having rather
# than continually restarting on initialization failure.
exit-on-error: false

# This section defines settings for the option HTTP proxy.
# This proxy can handle primary forwarding & replica consistency
# for applications that use a single SQLite database.
  addr: ':${INTERNAL_PORT}'
  target: 'localhost:${PORT}'
  db: "db"
    - "*.ico"
    - "*.png"

# This section defines a list of commands to run after LiteFS has connected
# and sync'd with the cluster. You can run multiple commands but LiteFS expects
# the last command to be long-running (e.g. an application server). When the
# last command exits, LiteFS is shut down.
  - cmd: "pnpm run:migrate"
    if-candidate: true
  - cmd: "node ./build/index.js --bind"

# The lease section specifies how the cluster will be managed. We're using the
# "consul" lease type so that our application can dynamically change the primary.
# These environment variables will be available in your application.
  type: "consul"
  advertise-url: "http://${HOSTNAME}.vm.${FLY_APP_NAME}.internal:20202"
  candidate: ${FLY_REGION == PRIMARY_REGION}
  promote: true

    url: "${FLY_CONSUL_URL}"
    key: "litefs/${FLY_APP_NAME}"

And this is my Dockerfile:

# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="SvelteKit"

# SvelteKit app lives here

# Set production environment
ENV NODE_ENV="production"

# Install pnpm
RUN npm install -g pnpm@$PNPM_VERSION

# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -y && apt-get install -y ca-certificates fuse3 sqlite3
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link .npmrc package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod=false

# Copy application code
COPY --link . .

# Build application
RUN pnpm run build

# Remove development dependencies
RUN pnpm prune --prod

# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app/build /app/build
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/package.json /app

ADD litefs.yml /etc/litefs.yml
COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs
RUN mkdir -p /data /litefs

# Start the server by default, this can be overwritten at runtime
ENV SQLITE_DATABASE_NAME="file:///litefs/sqlite.db"

CMD [ "litefs", "mount" ]

Also I’m a bit confused here as to which one is the path that my application will use to load the SQLite database, is it the /litefs folder?


From App not working to Build debugging

Added litefs

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