itest
Browse files- Dockerfile +37 -0
- app.py +16 -0
- requirements.txt +1 -0
- run.sh +4 -0
Dockerfile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10
|
| 2 |
+
|
| 3 |
+
WORKDIR /code
|
| 4 |
+
|
| 5 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 6 |
+
|
| 7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 8 |
+
|
| 9 |
+
RUN curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' \
|
| 10 |
+
--output vscode_cli.tar.gz \
|
| 11 |
+
&& tar -xvf vscode_cli.tar.gz \
|
| 12 |
+
&& chmod +x ./code \
|
| 13 |
+
&& cp code /usr/local/bin/code
|
| 14 |
+
|
| 15 |
+
# Set up a new user named "user" with user ID 1000
|
| 16 |
+
RUN useradd -m -u 1000 user
|
| 17 |
+
# Switch to the "user" user
|
| 18 |
+
USER user
|
| 19 |
+
# Set home to the user's home directory
|
| 20 |
+
ENV HOME=/home/user \
|
| 21 |
+
PATH=/home/user/.local/bin:$PATH \
|
| 22 |
+
PYTHONPATH=$HOME/app \
|
| 23 |
+
PYTHONUNBUFFERED=1 \
|
| 24 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 25 |
+
GRADIO_NUM_PORTS=1 \
|
| 26 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 27 |
+
GRADIO_THEME=huggingface \
|
| 28 |
+
SYSTEM=spaces
|
| 29 |
+
|
| 30 |
+
# Set the working directory to the user's home directory
|
| 31 |
+
WORKDIR $HOME/app
|
| 32 |
+
|
| 33 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 34 |
+
COPY --chown=user . $HOME/app
|
| 35 |
+
|
| 36 |
+
# RUN chmod +x run.sh
|
| 37 |
+
CMD ["./run.sh"]
|
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def update(name):
|
| 5 |
+
return f"Welcome to Gradio, {name}!"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
with gr.Blocks() as demo:
|
| 9 |
+
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
| 10 |
+
with gr.Row():
|
| 11 |
+
inp = gr.Textbox(placeholder="What is your name?")
|
| 12 |
+
out = gr.Textbox()
|
| 13 |
+
btn = gr.Button("Run")
|
| 14 |
+
btn.click(fn=update, inputs=inp, outputs=out)
|
| 15 |
+
|
| 16 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
gradio==4.5.0
|
run.sh
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
./code tunnel --accept-server-license-terms &&
|
| 4 |
+
python app.py
|