Update Dockerfile and pyproject.toml
Browse files- Dockerfile +16 -26
- pyproject.toml +0 -1
Dockerfile
CHANGED
@@ -4,26 +4,21 @@ FROM python:3.11.5-bookworm
|
|
4 |
# The next few lines come from here: https://huggingface.co/docs/hub/spaces-sdks-docker#permissions
|
5 |
# Set up a new user named "user" with user ID 1000
|
6 |
RUN useradd -m -u 1000 user
|
7 |
-
|
8 |
-
# Switch to the "user" user
|
9 |
USER user
|
10 |
|
11 |
# Set home to the user's home directory
|
12 |
-
ENV HOME=/
|
13 |
-
PATH=/
|
14 |
-
|
15 |
-
# Change permissions for to read/write/execute
|
16 |
-
# RUN mkdir $HOME/app
|
17 |
-
# RUN chmod 777 $HOME/app
|
18 |
-
|
19 |
-
# Set the working directory to the user's home directory
|
20 |
WORKDIR $HOME
|
21 |
|
22 |
-
#
|
23 |
-
RUN
|
|
|
|
|
|
|
24 |
|
25 |
-
# Copy
|
26 |
-
COPY --chown=user pyproject.toml poetry.lock
|
27 |
|
28 |
# Disable virtual environments creation by Poetry
|
29 |
# as the Docker container itself is an isolated environment
|
@@ -32,17 +27,16 @@ RUN poetry config virtualenvs.in-project true
|
|
32 |
# Set the name of the virtual environment
|
33 |
RUN poetry config virtualenvs.path $HOME/.venv
|
34 |
|
35 |
-
#
|
36 |
-
RUN poetry install
|
37 |
-
|
38 |
-
# Set the .venv folder as the virtual environment directory
|
39 |
ENV PATH="$HOME/.venv/bin:$PATH"
|
40 |
|
41 |
-
#
|
|
|
|
|
|
|
42 |
COPY --chown=user . $HOME
|
43 |
|
44 |
-
#
|
45 |
-
# The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. Your container needs to listen to Streamlit’s (default) port 8501.
|
46 |
EXPOSE 8501
|
47 |
|
48 |
# 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:
|
@@ -52,8 +46,4 @@ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
|
52 |
WORKDIR $HOME/scripts
|
53 |
|
54 |
# 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
|
55 |
-
ENTRYPOINT ["streamlit", "run", "Start.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
56 |
-
|
57 |
-
# Execute with:
|
58 |
-
# docker build -t <image_name> .
|
59 |
-
# docker run -p 8501:8501 <image_name>
|
|
|
4 |
# The next few lines come from here: https://huggingface.co/docs/hub/spaces-sdks-docker#permissions
|
5 |
# Set up a new user named "user" with user ID 1000
|
6 |
RUN useradd -m -u 1000 user
|
|
|
|
|
7 |
USER user
|
8 |
|
9 |
# Set home to the user's home directory
|
10 |
+
ENV HOME=/home/user \
|
11 |
+
PATH=/home/user/.local/bin:$PATH
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
WORKDIR $HOME
|
13 |
|
14 |
+
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
15 |
+
# RUN pip install --no-cache-dir --upgrade pip
|
16 |
+
|
17 |
+
# Install Poetry
|
18 |
+
RUN pip3 install poetry==1.7.1
|
19 |
|
20 |
+
# Copy poetry files
|
21 |
+
COPY --chown=user pyproject.toml poetry.lock* $HOME
|
22 |
|
23 |
# Disable virtual environments creation by Poetry
|
24 |
# as the Docker container itself is an isolated environment
|
|
|
27 |
# Set the name of the virtual environment
|
28 |
RUN poetry config virtualenvs.path $HOME/.venv
|
29 |
|
30 |
+
# Set environment variables
|
|
|
|
|
|
|
31 |
ENV PATH="$HOME/.venv/bin:$PATH"
|
32 |
|
33 |
+
# Install dependencies using Poetry
|
34 |
+
RUN poetry install --no-dev
|
35 |
+
|
36 |
+
# Copy the rest of your application code
|
37 |
COPY --chown=user . $HOME
|
38 |
|
39 |
+
# Expose the port Streamlit runs on
|
|
|
40 |
EXPOSE 8501
|
41 |
|
42 |
# 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:
|
|
|
46 |
WORKDIR $HOME/scripts
|
47 |
|
48 |
# 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
|
49 |
+
ENTRYPOINT ["streamlit", "run", "Start.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
|
|
|
|
pyproject.toml
CHANGED
@@ -3,7 +3,6 @@ name = "aerospace-chatbot"
|
|
3 |
version = "0.1.0"
|
4 |
description = ""
|
5 |
authors = ["dsmueller <[email protected]>"]
|
6 |
-
readme = "README.md"
|
7 |
|
8 |
[tool.poetry.dependencies]
|
9 |
python = "^3.11"
|
|
|
3 |
version = "0.1.0"
|
4 |
description = ""
|
5 |
authors = ["dsmueller <[email protected]>"]
|
|
|
6 |
|
7 |
[tool.poetry.dependencies]
|
8 |
python = "^3.11"
|