Skip to content

Commit

Permalink
Standalone server with database (promptfoo#118)
Browse files Browse the repository at this point in the history
Notable changes:

    Foundations for a shared database, so that a team can collaborate on evals
    Enable self-hosting, so that sharing is possible without relying on the www.promptfoo.dev host
    Users can run evals directly through the hosted web UI without running promptfoo locally (good for non-technical prompt writers)

Lots of tangentially related cleanup along the way, including:

    Making providers consistently handle config, and adding support for config.apiKey across providers
    Improve the formatting and verbosity of errors in the table view

Related to promptfoo#99
  • Loading branch information
typpo authored Aug 27, 2023
1 parent c57df21 commit 7cf0d09
Show file tree
Hide file tree
Showing 53 changed files with 2,528 additions and 5,581 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ Dockerfile
*.log
.DS_Store
.aider*
.env*
dist
scratch
*.sqlite

src/web/nextui/node_modules
src/web/nextui/.next
src/web/nextui/out
src/web/nextui/.env
30 changes: 23 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
FROM node:16-alpine
ENV PROMPTFOO_STANDALONE_SERVER=1
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile

WORKDIR /app
# ---- Build ----
FROM node:16-alpine AS builder
ENV NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER=1

WORKDIR /app
COPY . .

WORKDIR /app/src/web/nextui
# Envars are read in from src/web/nextui/.env.production
RUN echo "*** Building with env vars from .env.production"

# TODO(ian): Modify to multistep build so we don't carry over development packages
RUN npm install
RUN npm run build

WORKDIR /app/src/web/nextui
RUN npm prune --production

# ---- Final Stage ----
FROM node:16-alpine

WORKDIR /app

COPY --from=builder /app/src/web/nextui/public ./public
COPY --from=builder /app/src/web/nextui/.next/standalone ./
COPY --from=builder /app/src/web/nextui/.next/static ./.next/static

EXPOSE 3000

CMD ["npm", "start"]
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

CMD ["node", "server.js"]
20 changes: 20 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# fly.toml app configuration file generated for promptfoo-web on 2023-08-26T20:54:31-07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "promptfoo-web"
primary_region = "sjc"

[env]
NODE_ENV = "production"

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
Loading

0 comments on commit 7cf0d09

Please sign in to comment.