Skip to content

Instantly share code, notes, and snippets.

@nocksock
Last active January 17, 2025 09:15
Show Gist options
  • Save nocksock/2c750d73fef5caff6c43c06038d0a9ca to your computer and use it in GitHub Desktop.
Save nocksock/2c750d73fef5caff6c43c06038d0a9ca to your computer and use it in GitHub Desktop.
Deploy ObservableHQ Framework on fly.io

Deploy ObservableHQ Framework on fly.io

Prerequisites

  • Account at fly.io.
  • fly's cli is installed and authenticated.
  • A Framework project.

Steps

  1. Put these files in the root of your Framework project. ie: the same folder as the observablehq.config.js
  2. Adjust value for app and likely primary_region in fly.toml
  3. Run fly launch

Run production build locally

  1. Make sure a docker daemon is running. ie: Docker, Orbstack or similar.
  2. In the root of your poject, run: docker run -p 3000:80 $(docker build -q .)
  3. Open http://localhost:3000 in your browser
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
app = 'YOUR-FRAMEWORK'
primary_region = 'ams'
[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
# STAGE: BUILD
FROM node:22 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . ./
RUN npm run build
# STAGE: SERVE
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri.html $uri/ /index.html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment