Repository: promptfoo/promptfoo
Issue: The dockerfile for sharing seems to be missing files
Root cause: Configuration Error

Hello,

First of all, thanks for creating the self-hosting feature. I tried running the dockerfile but the final stage docker compilation seems to be missing certain files and node server.js does not seem to start as a result of that.

For example:
docker run -p 3000:3000 promptfoo-ui
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
[Error: ENOENT: no such file or directory, open '/app/.next/BUILD_ID'] {
  type: 'Error',
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/app/.next/BUILD_ID'
}

If I do add the copy commands to the docker file it seems to complain about:
[Error: ENOENT: no such file or directory, open '/app/.next/prerender-manifest.json'] {
  type: 'Error',
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/app/.next/prerender-manifest.json'
}

I don't see this file in .next, I see is prerender-manifest.js instead


Do you see any errors during `docker build`?  It looks like maybe the next.js app failed to build somehow

> Do you see any errors during `docker build`? It looks like maybe the next.js app failed to build somehow

No errors in docker build, this happens during docker run

Can you paste the full output of `docker build`?

docker build --build-arg NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL=http://localhost:3000/api -t promptfoo-ui .
[+] Building 140.5s (15/15) FINISHED                                                                                                                                  
 => [internal] load build definition from Dockerfile                                                                                                             0.0s
 => => transferring dockerfile: 957B                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                0.0s
 => => transferring context: 265B                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/node:18-alpine                                                                                                0.5s
 => [internal] load build context                                                                                                                                0.3s
 => => transferring context: 10.74MB                                                                                                                             0.3s
 => [builder 1/7] FROM docker.io/library/node:18-alpine@sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f627aa6157cb98bc65c801efa2                                  0.1s
 => => resolve docker.io/library/node:18-alpine@sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f627aa6157cb98bc65c801efa2                                          0.0s
 => => sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f627aa6157cb98bc65c801efa2 1.43kB / 1.43kB                                                                   0.0s
 => => sha256:8842b060b01af71c082cee310b428a2d825e940d9fd9e450e05d726aea66a480 1.16kB / 1.16kB                                                                   0.0s
 => => sha256:f3776b60850deec9eb1da7746fa20b3f000bf153408dc896d6606704c83f948d 7.14kB / 7.14kB                                                                   0.0s
 => [builder 2/7] WORKDIR /app                                                                                                                                   0.1s
 => [builder 3/7] COPY . .                                                                                                                                       0.1s
 => [builder 4/7] RUN echo "*** Building with env vars from .env.production"                                                                                     0.2s
 => [builder 5/7] RUN npm install                                                                                                                              133.4s
 => [builder 6/7] WORKDIR /app/src/web/nextui                                                                                                                    0.0s
 => [builder 7/7] RUN npm prune --production                                                                                                                     3.2s
 => [stage-1 3/5] COPY --from=builder /app/src/web/nextui/public ./public                                                                                        0.0s 
 => [stage-1 4/5] COPY --from=builder /app/src/web/nextui/.next/standalone ./                                                                                    0.3s 
 => [stage-1 5/5] COPY --from=builder /app/src/web/nextui/.next/static ./.next/static                                                                            0.0s 
 => exporting to image                                                                                                                                           0.3s 
 => => exporting layers                                                                                                                                          0.3s
 => => writing image sha256:356d53b696cdd19259fa32144d80d18acef5671d846eb6868ddb58ce0feb776e                                                                     0.0s
 => => naming to docker.io/library/promptfoo-ui  

I think I know what might be wrong.  Please try creating a dummy `.env.production` file in `src/web/nextui` with these placeholder variables:

```
NEXT_PUBLIC_PROMPTFOO_WITH_DATABASE=1
NEXT_PUBLIC_SUPABASE_URL=https://
NEXT_PUBLIC_SUPABASE_ANON_KEY=abc
```

Rebuild and give it a try.  If it works, that will confirm the issue :)

That seems to have worked, thanks! 

Along those lines, why do I need to sign in/sign up to look at the evals. If I try to sign up it seems to fail to fetch.

https://auth/v1/signup?redirect_to=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fcallback


Moreover, when using the promptfoo share command it seems to fail as well:

PROMPTFOO_REMOTE_API_BASE_URL=http://localhost:3000/api PROMPTFOO_REMOTE_APP_BASE_URL=http://localhost:3000 promptfoo share -y

/usr/local/share/npm-global/lib/node_modules/promptfoo/node_modules/node-fetch/lib/index.js:1501
                        reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
                               ^
FetchError: request to http://localhost:3000/api/eval failed, reason: connect ECONNREFUSED 127.0.0.1:3000
    at ClientRequest.<anonymous> (/usr/local/share/npm-global/lib/node_modules/promptfoo/node_modules/node-fetch/lib/index.js:1501:11)
    at ClientRequest.emit (node:events:514:28)
    at Socket.socketErrorListener (node:_http_client:495:9)
    at Socket.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED'
}

Looks like the server isn't running on localhost:3000

On Fri, Jan 26, 2024, 12:10 PM Karthik Nathan ***@***.***>
wrote:

> Moreover, when using the promptfoo share command it seems to fail as well:
>
> PROMPTFOO_REMOTE_API_BASE_URL=http://localhost:3000/api
> PROMPTFOO_REMOTE_APP_BASE_URL=http://localhost:3000 promptfoo share -y
>
>
> /usr/local/share/npm-global/lib/node_modules/promptfoo/node_modules/node-fetch/lib/index.js:1501
> reject(new FetchError(request to ${request.url} failed, reason:
> ${err.message}, 'system', err));
> ^
> FetchError: request to http://localhost:3000/api/eval failed, reason:
> connect ECONNREFUSED 127.0.0.1:3000
> at ClientRequest.
> (/usr/local/share/npm-global/lib/node_modules/promptfoo/node_modules/node-fetch/lib/index.js:1501:11)
> at ClientRequest.emit (node:events:514:28)
> at Socket.socketErrorListener (node:_http_client:495:9)
> at Socket.emit (node:events:514:28)
> at emitErrorNT (node:internal/streams/destroy:151:8)
> at emitErrorCloseNT (node:internal/streams/destroy:116:3)
> at process.processTicksAndRejections
> (node:internal/process/task_queues:82:21) {
> type: 'system',
> errno: 'ECONNREFUSED',
> code: 'ECONNREFUSED'
> }
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/promptfoo/promptfoo/issues/412#issuecomment-1912629661>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACLYJVBLDIN7RMRSECO4PTYQQET7AVCNFSM6AAAAABCKZA5CGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJSGYZDSNRWGE>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>


Yeah, I'll figure that out but the problem seems to be in the Evals page. When I click that button I see the following in from the server:

TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error: getaddrinfo ENOTFOUND auth
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
      at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:128:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'auth'
  }


That just means the server is unreachable :)

On Fri, Jan 26, 2024 at 12:24 PM Karthik Nathan ***@***.***>
wrote:

> Yeah, I'll figure that out but the problem seems to be in the Evals page.
> When I click that button I see the following in from the server:
>
> TypeError: fetch failed
> at Object.fetch (node:internal/deps/undici/undici:11730:11)
> at process.processTicksAndRejections
> (node:internal/process/task_queues:95:5) {
> cause: Error: getaddrinfo ENOTFOUND auth
> at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
> at GetAddrInfoReqWrap.callbackTrampoline
> (node:internal/async_hooks:128:17) {
> errno: -3008,
> code: 'ENOTFOUND',
> syscall: 'getaddrinfo',
> hostname: 'auth'
> }
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/promptfoo/promptfoo/issues/412#issuecomment-1912650488>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACLYJT5IUYXDXJNGFO2KWTYQQGGPAVCNFSM6AAAAABCKZA5CGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJSGY2TANBYHA>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>


I don't think so, there seems to be an issue with the auth route, the evals page asks me to sign up or log in and clicking either button shows me the above response.

For more context, when I click the share button on a promptfoo session that's hosted on 15500, I do see the run in the dataset and prompts tab along with the eval id. However, if I click the eval id I run into:

TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11730:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: Error: getaddrinfo ENOTFOUND auth
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:128:17) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'auth'
}

Hmm, are you able to see in the network tab which URL it tries to fetch?

![Screenshot 2024-02-01 at 5 23 11 PM](https://github.com/promptfoo/promptfoo/assets/29498224/e53ba251-40bd-47bc-a0e0-9f36b8418124)


> ![Screenshot 2024-02-01 at 5 23 11 PM](https://private-user-images.githubusercontent.com/29498224/301664661-e53ba251-40bd-47bc-a0e0-9f36b8418124.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDcyMjk1NTQsIm5iZiI6MTcwNzIyOTI1NCwicGF0aCI6Ii8yOTQ5ODIyNC8zMDE2NjQ2NjEtZTUzYmEyNTEtNDBiZC00N2JjLWEwZTAtOWYzNmI4NDE4MTI0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMjA2VDE0MjA1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVmNjYzM2Y5Mjc0YjdkMDNlN2FlN2YxNzkzZGZhNGVkNGJkMjBmNTU1NTE3ZTQxYTgxMjAxMDdhMTBkZjMxNzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TjRFyLzpU0VY2YMyzMzwNjZ1xVn76zPVjhmVsDWNcxk)

hey，guys，have you solved this problem ? I met  this question the same to you, I do not have idea 

The Dockerfile released in 0.42.0 contains updates that should resolve issues with self-hosting the share functionality described here: https://promptfoo.dev/docs/usage/sharing/#self-hosting.  Please let me know if not the case!

I did try 0.42.0, the issue persists

- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11731:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error: getaddrinfo ENOTFOUND placeholder.promptfoo.dev
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
      at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:128:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'placeholder.promptfoo.dev'
  }
}