Spaces:
Build error
Build error
Updated with spotlight modifications
Browse files- Dockerfile +54 -28
Dockerfile
CHANGED
@@ -1,41 +1,46 @@
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.11.5-bookworm
|
3 |
|
4 |
-
#
|
5 |
-
# Set up a new user named "user" with user ID 1000
|
6 |
-
RUN useradd -m -u 1000 user
|
7 |
-
USER user
|
8 |
-
|
9 |
-
# Clone aerospace-chatbot github repository
|
10 |
USER root
|
11 |
-
WORKDIR /clonedir
|
12 |
-
RUN apt-get update && \
|
13 |
-
apt-get install -y git
|
14 |
-
RUN git clone --depth 1 https://github.com/dan-s-mueller/aerospace_chatbot.git .
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
USER user
|
|
|
|
|
18 |
ENV HOME=/home/user \
|
19 |
PATH=/home/user/.local/bin:$PATH
|
20 |
WORKDIR $HOME
|
21 |
|
22 |
# Create directories for the app code to be copied into
|
23 |
-
RUN mkdir $HOME/app
|
24 |
-
RUN mkdir $HOME/src
|
25 |
-
RUN mkdir $HOME/data
|
26 |
RUN mkdir $HOME/config
|
27 |
|
28 |
-
#
|
29 |
-
RUN
|
30 |
-
|
31 |
-
|
|
|
32 |
|
33 |
# Install Poetry
|
34 |
RUN pip3 install poetry==1.7.1
|
35 |
|
36 |
# Copy poetry files from repo into home
|
37 |
-
RUN cp /clonedir/pyproject.toml
|
38 |
-
RUN chown user:user $HOME/pyproject.toml
|
39 |
|
40 |
# Disable virtual environments creation by Poetry as the Docker container itself is an isolated environment
|
41 |
RUN poetry config virtualenvs.in-project true
|
@@ -49,26 +54,47 @@ ENV PATH="$HOME/.venv/bin:$PATH"
|
|
49 |
# Install dependencies using Poetry
|
50 |
RUN poetry install --no-root
|
51 |
|
52 |
-
# Copy the rest of
|
|
|
|
|
|
|
|
|
53 |
RUN cp -R /clonedir/src /clonedir/data /clonedir/config /clonedir/app $HOME
|
54 |
RUN chown -R user:user $HOME/src $HOME/data $HOME/config $HOME/db
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
# Expose the port Streamlit runs on
|
57 |
EXPOSE 8501
|
|
|
58 |
|
59 |
# The HEALTHCHECK instruction tells Docker how to test a container to check that it is still working. Your container needs to listen to Streamlit’s (default) port 8501:
|
60 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
61 |
|
62 |
-
#
|
63 |
-
|
64 |
-
|
65 |
-
# An ENTRYPOINT allows you to configure a container that will run as an executable. Here, it also contains the entire streamlit run command for your app, so you don’t have to call it from the command line
|
66 |
ENTRYPOINT ["streamlit", "run", "Home.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
67 |
|
|
|
|
|
|
|
68 |
# To run locally
|
69 |
-
# docker build -t
|
70 |
-
# docker run -p 8501:8501
|
|
|
|
|
|
|
|
|
71 |
|
72 |
# To run remotely from hugging face spaces
|
73 |
-
# docker run -it -p 7860:7860 --platform=linux/amd64 \
|
74 |
# registry.hf.space/ai-aerospace-aerospace-chatbots:latest
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.11.5-bookworm
|
3 |
|
4 |
+
# Do root things: clone repo and install dependencies. libsndfile1 for spotlight. libhdf5-serial-dev for vector distance.
|
|
|
|
|
|
|
|
|
|
|
5 |
USER root
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
RUN useradd -m -u 1000 user && chown -R user:user /home/user && chmod -R 777 /home/user
|
8 |
+
|
9 |
+
# WORKDIR /clonedir
|
10 |
+
# RUN apt-get update && \
|
11 |
+
# apt-get install -y git
|
12 |
+
# RUN git clone --depth 1 https://github.com/dan-s-mueller/aerospace_chatbot.git .
|
13 |
+
|
14 |
+
RUN apt-get update && apt-get install -y \
|
15 |
+
libhdf5-serial-dev \
|
16 |
+
libsndfile1 \
|
17 |
+
&& rm -rf /var/lib/apt/lists/*
|
18 |
+
|
19 |
USER user
|
20 |
+
|
21 |
+
# Set home to the user's home directory
|
22 |
ENV HOME=/home/user \
|
23 |
PATH=/home/user/.local/bin:$PATH
|
24 |
WORKDIR $HOME
|
25 |
|
26 |
# Create directories for the app code to be copied into
|
27 |
+
RUN mkdir $HOME/app
|
28 |
+
RUN mkdir $HOME/src
|
29 |
+
RUN mkdir $HOME/data
|
30 |
RUN mkdir $HOME/config
|
31 |
|
32 |
+
# Give all users read/write permissions to the app code directories
|
33 |
+
RUN chmod 777 $HOME/app
|
34 |
+
RUN chmod 777 $HOME/src
|
35 |
+
RUN chmod 777 $HOME/data
|
36 |
+
RUN chmod 777 $HOME/config
|
37 |
|
38 |
# Install Poetry
|
39 |
RUN pip3 install poetry==1.7.1
|
40 |
|
41 |
# Copy poetry files from repo into home
|
42 |
+
RUN cp /clonedir/pyproject.toml $HOME
|
43 |
+
RUN chown user:user $HOME/pyproject.toml
|
44 |
|
45 |
# Disable virtual environments creation by Poetry as the Docker container itself is an isolated environment
|
46 |
RUN poetry config virtualenvs.in-project true
|
|
|
54 |
# Install dependencies using Poetry
|
55 |
RUN poetry install --no-root
|
56 |
|
57 |
+
# Copy the rest of your application code. Use cp for github config, followed by chown statements. cp commands for non-local builds.
|
58 |
+
# COPY --chown=user:user ./src $HOME/src
|
59 |
+
# COPY --chown=user:user ./data $HOME/data
|
60 |
+
# COPY --chown=user:user ./config $HOME/config
|
61 |
+
# COPY --chown=user:user ./app $HOME/app
|
62 |
RUN cp -R /clonedir/src /clonedir/data /clonedir/config /clonedir/app $HOME
|
63 |
RUN chown -R user:user $HOME/src $HOME/data $HOME/config $HOME/db
|
64 |
|
65 |
+
# Set up database path and env variabole. Comment out if running on hugging face spaces
|
66 |
+
# RUN mkdir $HOME/db
|
67 |
+
# RUN chmod 777 $HOME/db
|
68 |
+
# ENV LOCAL_DB_PATH=$HOME/db
|
69 |
+
|
70 |
+
# Set final work directory for the application
|
71 |
+
WORKDIR $HOME/app
|
72 |
+
RUN pwd
|
73 |
+
RUN ls -R
|
74 |
+
|
75 |
# Expose the port Streamlit runs on
|
76 |
EXPOSE 8501
|
77 |
+
EXPOSE 9000
|
78 |
|
79 |
# The HEALTHCHECK instruction tells Docker how to test a container to check that it is still working. Your container needs to listen to Streamlit’s (default) port 8501:
|
80 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
81 |
|
82 |
+
# An ENTRYPOINT allows you to configure a container that will run as an executable.
|
83 |
+
# Here, it also contains the entire streamlit run command for your app, so you don’t have to call it from the command line
|
84 |
+
# Port 9000 will not be accessible from the hugging face space.
|
|
|
85 |
ENTRYPOINT ["streamlit", "run", "Home.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
86 |
|
87 |
+
# Run this if you're running with terminal locally
|
88 |
+
# ENTRYPOINT ["/bin/bash", "-c"]
|
89 |
+
|
90 |
# To run locally
|
91 |
+
# docker build -t aerospace-chatbot .
|
92 |
+
# docker run --user 1000:1000 -p 8501:8501 -p 9000:9000 -it aerospace-chatbot
|
93 |
+
|
94 |
+
# To run locally with a terminal.
|
95 |
+
# docker build -t aerospace-chatbot .
|
96 |
+
# docker run --user 1000:1000 --entrypoint /bin/bash -it aerospace-chatbot
|
97 |
|
98 |
# To run remotely from hugging face spaces
|
99 |
+
# docker run -it --user 1000:1000 -p 7860:7860 --platform=linux/amd64 \
|
100 |
# registry.hf.space/ai-aerospace-aerospace-chatbots:latest
|