I have a client app built with Vite React. This is a frontend app, which makes calls to an api/backend app.
The general problem is: When I navigate to my deployed app with fly (eg: app.fly.dev
), it’s an empty page. I have verified that the CSS and JS are being loaded. I have even ssh-ed into the instance to verify that everything from dist
is there.
I have also verified locally that pnpm build
and pnpm preview
both work and are displaying the app.
I have also verified locally that the Dockerfile can be built and run and the container is displaying the app.
At this point, I really feel like fly.io is the issue here. Maybe I’m not setting up my fly.toml
properly, although this is the one I got autogenerated from fly.io.
I would appreciate any tips for this.
Here is my fly.toml
file:
# fly.toml app configuration file generated for client-*** on 2025-01-22T19:52:49+01:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = 'client-***'
primary_region = 'fra'
[build]
[http_service]
internal_port = 80
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
Here is my Dockerfile:
# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired
ARG NODE_VERSION=22.11.0
FROM node:${NODE_VERSION}-slim AS base
LABEL fly_launch_runtime="Vite"
# Vite app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV="production"
# Install pnpm
ARG PNPM_VERSION=9.15.1
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 -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
# Install node modules
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod=false
# Copy application code
COPY . .
# Build application
RUN pnpm run build
# Remove development dependencies
RUN pnpm prune --prod
# Final stage for app image
FROM nginx
# Copy built application
COPY --from=build /app/dist /usr/share/nginx/html
# Start the server by default, this can be overwritten at runtime
EXPOSE 80
CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ]