first
Browse files- Dockerfile +31 -0
- app.py +16 -0
- environment.yml +7 -0
- run.sh +5 -0
Dockerfile
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM continuumio/anaconda3:main
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
COPY ./environment.yml /code/environment.yml
|
5 |
+
|
6 |
+
# Create the environment using the environment.yml file
|
7 |
+
RUN conda env create -f /code/environment.yml
|
8 |
+
|
9 |
+
# Set up a new user named "user" with user ID 1000
|
10 |
+
RUN useradd -m -u 1000 user
|
11 |
+
|
12 |
+
# Switch to the "user" user
|
13 |
+
USER user
|
14 |
+
|
15 |
+
# Set home to the user's home directory
|
16 |
+
ENV HOME=/home/user \
|
17 |
+
PYTHONPATH=$HOME/app \
|
18 |
+
PYTHONUNBUFFERED=1 \
|
19 |
+
GRADIO_ALLOW_FLAGGING=never \
|
20 |
+
GRADIO_NUM_PORTS=1 \
|
21 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
22 |
+
GRADIO_THEME=huggingface \
|
23 |
+
SYSTEM=spaces
|
24 |
+
|
25 |
+
# Set the working directory to the user's home directory
|
26 |
+
WORKDIR $HOME/app
|
27 |
+
|
28 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
29 |
+
COPY --chown=user . $HOME/app
|
30 |
+
|
31 |
+
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()
|
environment.yml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: gradio
|
2 |
+
channels:
|
3 |
+
- conda-forge
|
4 |
+
- defaults
|
5 |
+
dependencies:
|
6 |
+
- python=3.10
|
7 |
+
- gradio
|
run.sh
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
CONDA_ENV=$(head -1 /code/environment.yml | cut -d" " -f2)
|
3 |
+
eval "$(conda shell.bash hook)"
|
4 |
+
conda activate $CONDA_ENV
|
5 |
+
python app.py
|