h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
4.01k stars 328 forks source link

Error Running Docker Container on Apple Silicon #2309

Closed kevin-pek closed 5 months ago

kevin-pek commented 7 months ago

Wave SDK Version, OS

Wave SDK Version: h2o-wave==1.1.1 OS: macOS (Apple Silicon, M1) Docker Version: 24.0.2

Actual behavior

When trying to run a wave app using docker on my M1 Macbook, the container fails to start and this error is shown:

Could not connect to Wave server. Please start the Wave server (waved or waved.exe) prior to running any app.

Expected behavior

The container should start with no errors. The same dockerfile works as expected on windows, and also works on my mac when the build target platform is set to linux/amd64.

Steps To Reproduce

To quickly reproduce this issue, you can build and run the following image based on the wave init hello_world example on mac.

FROM python:3.10-slim

COPY . .

RUN pip install -r requirements.txt

CMD ["wave", "run", "app"]

The error described should be displayed when trying to start a container.

mturoci commented 7 months ago

Hi @kevin-pek, can you please provide a full docker build log? My gut feeling is that pip didn't pick the right wheel file.

kevin-pek commented 7 months ago

Sure! Here is the full build log:

#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 171B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/python:3.10-slim
#3 ...

#4 [auth] library/python:pull token for registry-1.docker.io
#4 DONE 0.0s

#3 [internal] load metadata for docker.io/library/python:3.10-slim
#3 DONE 3.4s

#5 [1/3] FROM docker.io/library/python:3.10-slim@sha256:64157e9ca781b9d18e4d7e613f4a3f19365a26d82da87ff1aa82a03eacb34687
#5 CACHED

#6 [internal] load build context
#6 transferring context: 50.30MB 1.0s done
#6 DONE 1.0s

#7 [2/3] COPY . .
#7 DONE 0.8s

#8 [3/3] RUN pip install -r requirements.txt
#8 1.369 Collecting h2o-wave==1.1.2
#8 1.445   Downloading h2o_wave-1.1.2-py3-none-any.whl (143 kB)
#8 1.467      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.2/143.2 kB 6.6 MB/s eta 0:00:00
#8 1.504 Collecting starlette>=0.13.8
#8 1.515   Downloading starlette-0.37.2-py3-none-any.whl (71 kB)
#8 1.518      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 71.9/71.9 kB 24.8 MB/s eta 0:00:00
#8 1.542 Collecting click
#8 1.553   Downloading click-8.1.7-py3-none-any.whl (97 kB)
#8 1.617      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 1.4 MB/s eta 0:00:00
#8 1.649 Collecting httpx>=0.16.1
#8 1.659   Downloading httpx-0.27.0-py3-none-any.whl (75 kB)
#8 1.662      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.6/75.6 kB 31.6 MB/s eta 0:00:00
#8 1.694 Collecting inquirer
#8 1.708   Downloading inquirer-3.2.4-py3-none-any.whl (18 kB)
#8 1.812 Collecting uvicorn>=0.17.6
#8 1.825   Downloading uvicorn-0.29.0-py3-none-any.whl (60 kB)
#8 1.833      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.8/60.8 kB 10.2 MB/s eta 0:00:00
#8 1.907 Collecting httpcore==1.*
#8 1.919   Downloading httpcore-1.0.5-py3-none-any.whl (77 kB)
#8 1.928      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.9/77.9 kB 12.8 MB/s eta 0:00:00
#8 1.966 Collecting certifi
#8 1.977   Downloading certifi-2024.2.2-py3-none-any.whl (163 kB)
#8 2.019      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 163.8/163.8 kB 5.4 MB/s eta 0:00:00
#8 2.048 Collecting sniffio
#8 2.059   Downloading sniffio-1.3.1-py3-none-any.whl (10 kB)
#8 2.116 Collecting anyio
#8 2.129   Downloading anyio-4.3.0-py3-none-any.whl (85 kB)
#8 2.137      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 85.6/85.6 kB 16.5 MB/s eta 0:00:00
#8 2.164 Collecting idna
#8 2.181   Downloading idna-3.7-py3-none-any.whl (66 kB)
#8 2.190      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.8/66.8 kB 13.8 MB/s eta 0:00:00
#8 2.225 Collecting h11<0.15,>=0.13
#8 2.235   Downloading h11-0.14.0-py3-none-any.whl (58 kB)
#8 2.241      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 13.5 MB/s eta 0:00:00
#8 2.305 Collecting typing-extensions>=4.0
#8 2.316   Downloading typing_extensions-4.11.0-py3-none-any.whl (34 kB)
#8 2.349 Collecting readchar>=3.0.6
#8 2.361   Downloading readchar-4.0.6-py3-none-any.whl (8.5 kB)
#8 2.387 Collecting editor>=1.6.0
#8 2.403   Downloading editor-1.6.6-py3-none-any.whl (4.0 kB)
#8 2.427 Collecting blessed>=1.19.0
#8 2.438   Downloading blessed-1.20.0-py2.py3-none-any.whl (58 kB)
#8 2.441      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.4/58.4 kB 23.6 MB/s eta 0:00:00
#8 2.474 Collecting exceptiongroup>=1.0.2
#8 2.484   Downloading exceptiongroup-1.2.0-py3-none-any.whl (16 kB)
#8 2.510 Collecting six>=1.9.0
#8 2.519   Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
#8 2.542 Collecting wcwidth>=0.1.4
#8 2.551   Downloading wcwidth-0.2.13-py2.py3-none-any.whl (34 kB)
#8 2.574 Collecting xmod
#8 2.583   Downloading xmod-1.8.1-py3-none-any.whl (4.6 kB)
#8 2.599 Collecting runs
#8 2.609   Downloading runs-1.2.2-py3-none-any.whl (7.0 kB)
#8 2.616 Requirement already satisfied: setuptools>=41.0 in /usr/local/lib/python3.10/site-packages (from readchar>=3.0.6->inquirer->h2o-wave==1.1.2->-r requirements.txt (line 1)) (65.5.1)
#8 2.707 Installing collected packages: wcwidth, xmod, typing-extensions, sniffio, six, readchar, idna, h11, exceptiongroup, click, certifi, uvicorn, runs, httpcore, blessed, anyio, starlette, httpx, editor, inquirer, h2o-wave
#8 3.379 Successfully installed anyio-4.3.0 blessed-1.20.0 certifi-2024.2.2 click-8.1.7 editor-1.6.6 exceptiongroup-1.2.0 h11-0.14.0 h2o-wave-1.1.2 httpcore-1.0.5 httpx-0.27.0 idna-3.7 inquirer-3.2.4 readchar-4.0.6 runs-1.2.2 six-1.16.0 sniffio-1.3.1 starlette-0.37.2 typing-extensions-4.11.0 uvicorn-0.29.0 wcwidth-0.2.13 xmod-1.8.1
#8 3.379 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#8 3.497
#8 3.497 [notice] A new release of pip is available: 23.0.1 -> 24.0
#8 3.497 [notice] To update, run: pip install --upgrade pip
#8 DONE 3.7s

#9 exporting to image
#9 exporting layers
#9 exporting layers 0.3s done
#9 writing image sha256:cfed51cdc6be19aa41cf3cbaada530c5c760ac9990d411ba883fec489bfcbd6b done
#9 naming to docker.io/library/h2o-wave done
#9 DONE 0.3s
mturoci commented 7 months ago

Thanks!

The problem is pip downloads platform agnostic wheel for Wave (and others) as it seems like it cannot detect the platform properly:

...
#8 1.445   Downloading h2o_wave-1.1.2-py3-none-any.whl (143 kB)
...

The solution is to either specify a docker platform (should work) or find another way to tell pip which platform it should download for or take it as is and download&run waved (wave server) manually.

kevin-pek commented 6 months ago

Thanks! I was also wondering if there is a page on the wave documentation that mentions that documents this? Or an example for how we can prepare a Dockerfile to download and run waved manually?

mturoci commented 6 months ago

Unfortunately, there is not since that is outside of scope for Wave (it's about Docker/pip).