andrewlee1807 commited on
Commit
e99c10f
·
1 Parent(s): f2be9d4
Files changed (2) hide show
  1. Dockerfile +13 -36
  2. app.py +1 -1
Dockerfile CHANGED
@@ -1,43 +1,20 @@
1
- # Accept Python version during build
2
- ARG PYTHON_VERSION="3.8"
3
 
4
- FROM python:${PYTHON_VERSION}-slim
 
 
5
 
6
- # Install OS dependencies
7
- RUN apt-get update && apt-get -y upgrade \
8
- && export DEBIAN_FRONTEND=noninteractive \
9
- && apt-get -y install --no-install-recommends curl build-essential
10
 
11
- # Create a non-root user
12
- RUN useradd --create-home appuser
13
- USER appuser
14
- WORKDIR /home/appuser/app
15
 
16
- # Install Wave
17
- ARG WAVE_VERSION="0.20.0"
18
 
19
- ENV WAVE_HOME="/home/appuser/wave"
20
- RUN \
21
- mkdir -p "${WAVE_HOME}" && \
22
- curl -fsSL https://github.com/h2oai/wave/releases/download/v${WAVE_VERSION}/wave-${WAVE_VERSION}-linux-amd64.tar.gz | tar -C ${WAVE_HOME} -xzv 2>&1
23
- ENV WAVE_PATH="${WAVE_HOME}/wave-${WAVE_VERSION}-linux-amd64"
24
 
25
- # Create a virtual environment
26
- ENV VIRTUAL_ENV=/home/appuser/venv
27
- RUN python3 -m venv $VIRTUAL_ENV
28
- ENV PATH="$VIRTUAL_ENV/bin:$PATH"
29
 
30
- # Install Python dependencies
31
- COPY requirements.txt .
32
- RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
33
-
34
- # Copy app code
35
- COPY --chown=appuser:appuser . .
36
-
37
- # Set permissions for the Entrypoint script
38
- RUN chmod +x docker-entrypoint.sh
39
-
40
- ARG PYTHON_MODULE
41
- ENV PYTHON_MODULE="${PYTHON_MODULE}"
42
-
43
- ENTRYPOINT [ "./docker-entrypoint.sh" ]
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
 
4
+ FROM python:3.8
5
+ # When running on M1 Mac, use the following --platform option.
6
+ # FROM --platform=linux/amd64 python:3.9
7
 
8
+ WORKDIR /code
 
 
 
9
 
10
+ COPY . .
 
 
 
11
 
12
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
13
 
 
 
 
 
 
14
 
15
+ # Change the port number of our Wave app to 7860
16
+ # which is default in Hugging Face Spaces.
17
+ ENV H2O_WAVE_LISTEN=":7860"
18
+ ENV H2O_WAVE_ADDRESS='http://127.0.0.1:7860'
19
 
20
+ CMD ["wave", "run", "app", "--no-reload"]
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -75,7 +75,7 @@ def on_shutdown():
75
  task_data = asyncio.create_task(api_get_data())
76
 
77
 
78
- @app('/sensor', on_startup=on_startup, on_shutdown=on_shutdown, mode='broadcast')
79
  async def sever(q: Q):
80
  apply_layout(q)
81
  show_homepage(q)
 
75
  task_data = asyncio.create_task(api_get_data())
76
 
77
 
78
+ @app('/', on_startup=on_startup, on_shutdown=on_shutdown, mode='broadcast')
79
  async def sever(q: Q):
80
  apply_layout(q)
81
  show_homepage(q)