derek-thomas
commited on
Commit
·
db451dd
1
Parent(s):
5027b18
Simplifying
Browse files- Dockerfile +69 -68
- app.py +1 -6
- requirements.txt +1 -1
Dockerfile
CHANGED
|
@@ -1,72 +1,73 @@
|
|
| 1 |
# Start from the TGI base image
|
| 2 |
-
FROM ghcr.io/huggingface/text-generation-inference:
|
| 3 |
|
| 4 |
COPY ./requirements.txt /code/requirements.txt
|
| 5 |
|
| 6 |
-
|
| 7 |
-
RUN pip install jupyterlab jupyterlab-vim==0.15.1 jupyterlab-vimrc
|
| 8 |
-
|
| 9 |
-
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
RUN curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' \
|
| 13 |
-
--output vscode_cli.tar.gz \
|
| 14 |
-
&& tar -xvf vscode_cli.tar.gz \
|
| 15 |
-
&& chmod +x ./code \
|
| 16 |
-
&& mv code /usr/local/bin/
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
RUN useradd -m -u 1000 -s /bin/bash user
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
RUN mkdir /data && chown user:user /data
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
USER user
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
WORKDIR /home/user
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
ENV PATH="/home/user/.local/bin:${PATH}"
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
FROM base as sagemaker
|
| 36 |
-
|
| 37 |
-
COPY sagemaker-entrypoint.sh entrypoint.sh
|
| 38 |
-
RUN chmod +x entrypoint.sh
|
| 39 |
-
|
| 40 |
-
ENTRYPOINT ["./entrypoint.sh"]
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
FROM base
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
ENTRYPOINT []
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
USER user
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
WORKDIR /home/user
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
ENV HOME=/home/user \
|
| 56 |
-
PATH=/home/user/.local/bin:$PATH \
|
| 57 |
-
PYTHONPATH=$HOME/app \
|
| 58 |
-
PYTHONUNBUFFERED=1 \
|
| 59 |
-
GRADIO_ALLOW_FLAGGING=never \
|
| 60 |
-
GRADIO_NUM_PORTS=1 \
|
| 61 |
-
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 62 |
-
GRADIO_THEME=huggingface \
|
| 63 |
-
SYSTEM=spaces
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
COPY --chown=user . $HOME/
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
RUN chmod +x $HOME/run.sh
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
CMD ["/home/user/run.sh"]
|
|
|
|
|
|
| 1 |
# Start from the TGI base image
|
| 2 |
+
FROM ghcr.io/huggingface/text-generation-inference:2.0 as base
|
| 3 |
|
| 4 |
COPY ./requirements.txt /code/requirements.txt
|
| 5 |
|
| 6 |
+
## Install JupyterLab and plugins
|
| 7 |
+
#RUN pip install jupyterlab jupyterlab-vim==0.15.1 jupyterlab-vimrc
|
| 8 |
+
#
|
| 9 |
+
#RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 10 |
+
#
|
| 11 |
+
## Install Visual Studio Code CLI
|
| 12 |
+
#RUN curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' \
|
| 13 |
+
# --output vscode_cli.tar.gz \
|
| 14 |
+
# && tar -xvf vscode_cli.tar.gz \
|
| 15 |
+
# && chmod +x ./code \
|
| 16 |
+
# && mv code /usr/local/bin/
|
| 17 |
+
#
|
| 18 |
+
## Create a non-root user with UID 1000
|
| 19 |
+
#RUN useradd -m -u 1000 -s /bin/bash user
|
| 20 |
+
#
|
| 21 |
+
## Create the /data directory and set its ownership
|
| 22 |
+
#RUN mkdir /data && chown user:user /data
|
| 23 |
+
#
|
| 24 |
+
## Switch to the non-root user
|
| 25 |
+
#USER user
|
| 26 |
+
#
|
| 27 |
+
## Set working directory
|
| 28 |
+
#WORKDIR /home/user
|
| 29 |
+
#
|
| 30 |
+
## Add local python bin directory to PATH
|
| 31 |
+
#ENV PATH="/home/user/.local/bin:${PATH}"
|
| 32 |
+
#
|
| 33 |
+
## AWS Sagemaker compatible image
|
| 34 |
+
## Assuming this part remains the same from your original Dockerfile
|
| 35 |
+
#FROM base as sagemaker
|
| 36 |
+
#
|
| 37 |
+
#COPY sagemaker-entrypoint.sh entrypoint.sh
|
| 38 |
+
#RUN chmod +x entrypoint.sh
|
| 39 |
+
#
|
| 40 |
+
#ENTRYPOINT ["./entrypoint.sh"]
|
| 41 |
+
#
|
| 42 |
+
## Final image
|
| 43 |
+
#FROM base
|
| 44 |
+
#
|
| 45 |
+
## Override the ENTRYPOINT
|
| 46 |
+
#ENTRYPOINT []
|
| 47 |
+
#
|
| 48 |
+
## Switch to the non-root user
|
| 49 |
+
#USER user
|
| 50 |
+
#
|
| 51 |
+
## Set working directory
|
| 52 |
+
#WORKDIR /home/user
|
| 53 |
+
#
|
| 54 |
+
## Set home to the user's home directory
|
| 55 |
+
#ENV HOME=/home/user \
|
| 56 |
+
# PATH=/home/user/.local/bin:$PATH \
|
| 57 |
+
# PYTHONPATH=$HOME/app \
|
| 58 |
+
# PYTHONUNBUFFERED=1 \
|
| 59 |
+
# GRADIO_ALLOW_FLAGGING=never \
|
| 60 |
+
# GRADIO_NUM_PORTS=1 \
|
| 61 |
+
# GRADIO_SERVER_NAME=0.0.0.0 \
|
| 62 |
+
# GRADIO_THEME=huggingface \
|
| 63 |
+
# SYSTEM=spaces
|
| 64 |
+
#
|
| 65 |
+
## Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 66 |
+
#COPY --chown=user . $HOME/
|
| 67 |
+
#
|
| 68 |
+
## Ensure run.sh is executable
|
| 69 |
+
#RUN chmod +x $HOME/run.sh
|
| 70 |
+
#
|
| 71 |
+
## Set the CMD to run your script
|
| 72 |
+
#CMD ["/home/user/run.sh"]
|
| 73 |
+
python app.py
|
app.py
CHANGED
|
@@ -6,11 +6,6 @@ def update(name):
|
|
| 6 |
|
| 7 |
|
| 8 |
with gr.Blocks() as demo:
|
| 9 |
-
gr.Markdown("
|
| 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()
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
with gr.Blocks() as demo:
|
| 9 |
+
gr.Markdown("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
demo.launch()
|
requirements.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
gradio==4.
|
|
|
|
| 1 |
+
gradio==4.26.0
|