Repository: promptfoo/promptfoo
Issue: Using Podman Desktop ,on a Mac M1 the docker build not working and hangs at - info Creating an optimized production build...
Root cause: Environment Incompatibility

```
➜  docker docker build --build-arg NEXT_PUBLIC_PROMPTFOO_BASE_URL=http://localhost:3000 -t promptfoo-ui .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /Users/raghurambanda/docker/Dockerfile: no such file or directory
➜  docker ls
promptfoo
➜  docker cd promptfoo 
➜  promptfoo git:(main) ✗ docker build --build-arg NEXT_PUBLIC_PROMPTFOO_BASE_URL=http://localhost:3000 -t promptfoo-ui .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
➜  promptfoo git:(main) ✗ docker build --build-arg NEXT_PUBLIC_PROMPTFOO_BASE_URL=http://localhost:3000 -t promptfoo-ui .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  19.71MB
time="2024-07-20T01:01:47-04:00" level=warning msg="missing \"NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL\" build argument. Try adding \"--build-arg NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL=<VALUE>\" to the command line"
time="2024-07-20T01:01:47-04:00" level=warning msg="missing \"NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE\" build argument. Try adding \"--build-arg NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE=<VALUE>\" to the command line"
[1/2] STEP 1/19: FROM node:20-alpine AS builder
WARNING: image platform (linux/amd64) does not match the expected platform (linux/arm64)
[1/2] STEP 2/19: ARG NEXT_PUBLIC_PROMPTFOO_BASE_URL
--> Using cache 2594d3c2802835c165a66b44e0584a3a4f2cc4ecab0b63aaa828a3b69e1910fb
--> 2594d3c28028
[1/2] STEP 3/19: ENV NEXT_PUBLIC_PROMPTFOO_BASE_URL=${NEXT_PUBLIC_PROMPTFOO_BASE_URL}
--> Using cache 9a733bbd71bd786bb7273fc5c1eead416c02d05374398206df37c9c54e335875
--> 9a733bbd71bd
[1/2] STEP 4/19: ENV NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER=1
--> Using cache 0deb6731d3abea55cdf3a3d8d8bffdab2343939e0d4c02b9f7f8d28f9461ee60
--> 0deb6731d3ab
[1/2] STEP 5/19: ENV NEXT_TELEMETRY_DISABLED=1
--> Using cache b119f146eb37431c968498a4afbda8350fbf26c901708a011d88d2b81f102c56
--> b119f146eb37
[1/2] STEP 6/19: ARG NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL
--> Using cache 64433057f91dc07b3004ae514bfc4fbad615792ce614fa7282537b85d8250a23
--> 64433057f91d
[1/2] STEP 7/19: ENV NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL=${NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL}
--> Using cache 8910dfebc9db54b401033ae7e834ad779cb904038d3c735f62adcebc9d43fb27
--> 8910dfebc9db
[1/2] STEP 8/19: ARG NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE
--> Using cache e178000798f1b18eba704dd8e1724ccf93b1b90da607648d0c72cd40e348c080
--> e178000798f1
[1/2] STEP 9/19: ENV NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE=${NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE}
--> Using cache 3f47c7da7a4406cd64ad4104e217369aa139164af6d639e156ffba9f5cc2d8c6
--> 3f47c7da7a44
[1/2] STEP 10/19: ENV NEXT_PUBLIC_SUPABASE_URL=http://placeholder.promptfoo.dev
--> Using cache c73304816af075df366920719f4df3bd6645d4df53e15008bbef30d3ba0249db
--> c73304816af0
[1/2] STEP 11/19: ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=placeholder
--> Using cache a91ef4b54477d371589e29a96f127d1590768e240bb68f33e733a9917eb3d8e3
--> a91ef4b54477
[1/2] STEP 12/19: WORKDIR /app
--> Using cache 697fa43dc26c39fb8d161981d69f5cff9b79a2bf9c082cbdeaa01615377c3454
--> 697fa43dc26c
[1/2] STEP 13/19: COPY . .
--> b648bb4054cb
[1/2] STEP 14/19: RUN apk update && apk add --no-cache python3 build-base
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
v3.20.1-161-g92564a0d909 [https://dl-cdn.alpinelinux.org/alpine/v3.20/main]
v3.20.1-163-gc21bd5e8a59 [https://dl-cdn.alpinelinux.org/alpine/v3.20/community]
OK: 24157 distinct packages available
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
(1/34) Installing jansson (2.14-r4)
(2/34) Installing zstd-libs (1.5.6-r0)
(3/34) Installing binutils (2.42-r0)
(4/34) Installing libmagic (5.45-r1)
(5/34) Installing file (5.45-r1)
(6/34) Installing libgomp (13.2.1_git20240309-r0)
(7/34) Installing libatomic (13.2.1_git20240309-r0)
(8/34) Installing gmp (6.3.0-r1)
(9/34) Installing isl26 (0.26-r1)
(10/34) Installing mpfr4 (4.2.1-r0)
(11/34) Installing mpc1 (1.3.1-r1)
(12/34) Installing gcc (13.2.1_git20240309-r0)
(13/34) Installing libstdc++-dev (13.2.1_git20240309-r0)
(14/34) Installing musl-dev (1.2.5-r0)
(15/34) Installing g++ (13.2.1_git20240309-r0)
(16/34) Installing make (4.4.1-r2)
(17/34) Installing fortify-headers (1.1-r3)
(18/34) Installing patch (2.7.6-r10)
(19/34) Installing build-base (0.5-r3)
(20/34) Installing libbz2 (1.0.8-r6)
(21/34) Installing libexpat (2.6.2-r0)
(22/34) Installing libffi (3.4.6-r0)
(23/34) Installing gdbm (1.23-r1)
(24/34) Installing xz-libs (5.6.1-r3)
(25/34) Installing mpdecimal (4.0.0-r0)
(26/34) Installing ncurses-terminfo-base (6.4_p20240420-r0)
(27/34) Installing libncursesw (6.4_p20240420-r0)
(28/34) Installing libpanelw (6.4_p20240420-r0)
(29/34) Installing readline (8.2.10-r0)
(30/34) Installing sqlite-libs (3.45.3-r1)
(31/34) Installing python3 (3.12.3-r1)
(32/34) Installing python3-pycache-pyc0 (3.12.3-r1)
(33/34) Installing pyc (3.12.3-r1)
(34/34) Installing python3-pyc (3.12.3-r1)
Executing busybox-1.36.1-r29.trigger
OK: 264 MiB in 50 packages
--> c2948993830f
[1/2] STEP 15/19: RUN echo "*** Building with env vars from .env.production"
*** Building with env vars from .env.production
--> 6f9ace39b144
[1/2] STEP 16/19: RUN npm install
npm warn skipping integrity check for git dependency ssh://git@github.com/kenlimmj/rouge.git

added 2298 packages, and audited 2301 packages in 1m

496 packages are looking for funding
  run `npm fund` for details

3 vulnerabilities (1 low, 1 moderate, 1 high)

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.
npm notice
npm notice New minor version of npm available! 10.7.0 -> 10.8.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.2
npm notice To update run: npm install -g npm@10.8.2
npm notice
--> 6d016d24885c
[1/2] STEP 17/19: RUN npm run build

> promptfoo@0.72.2 build
> tsc && shx cp src/*.html dist/src && shx cp src/python/wrapper.py dist/src/python && shx rm -rf dist/drizzle && shx cp -r drizzle dist/drizzle && npm run build:nextui && shx chmod +x dist/src/main.js


> promptfoo@0.72.2 build:nextui
> sh src/web/nextui/build.sh


> nextui@0.1.0 build
> next build

**************************************************
Building next.js in standalone mode
**************************************************
- info Creating an optimized production build...


```

How long did it hang for?  Creating an optimized production build can sometimes take a while.

@will-holley can you look into solving this as part of https://github.com/promptfoo/promptfoo/pull/1047 ? 

> @will-holley can you look into solving this as part of #1047 ?

Aside from moving the `dockerfile` into a consolidated directory (with the other docker files), #1047 doesn't concern the web build, so I'll address this, but in a separate PR.

Hi @rrbanda, thanks for your patience! We’ve made several updates to address Docker build issues, particularly for M1 Macs and container platforms like Podman. The build process should now work more smoothly, and we've consolidated the Docker files as part of ongoing improvements.

Since this issue has been open for a while and we’ve pushed updates that likely resolve it, I’m going to close it for now. However, if you’re still experiencing problems, feel free to reopen the issue or create a new one.

Thanks again for your feedback and for helping us improve!