Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +19 -25
Dockerfile
CHANGED
@@ -1,7 +1,15 @@
|
|
1 |
# Use the official Python slim image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
RUN apt-get update && apt-get install -y \
|
6 |
build-essential \
|
7 |
curl \
|
@@ -11,40 +19,26 @@ RUN apt-get update && apt-get install -y \
|
|
11 |
libblas-dev \
|
12 |
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
COPY
|
20 |
-
COPY ./index.md /usr/bin/code/index.md
|
21 |
|
22 |
# Install Poetry via pip
|
23 |
-
RUN pip install --upgrade pip
|
24 |
-
&& pip install poetry
|
25 |
|
|
|
26 |
RUN poetry install --no-root --only=main
|
27 |
|
28 |
# Expose the necessary port
|
29 |
EXPOSE 7860
|
30 |
|
31 |
-
# Copy the rest of your application code
|
32 |
-
COPY . /
|
33 |
-
|
34 |
-
# Create a user and switch to it
|
35 |
-
RUN useradd -m -u 1000 user
|
36 |
-
USER user
|
37 |
-
ENV HOME=/home/user \
|
38 |
-
PATH=/home/user/.local/bin:$PATH
|
39 |
-
|
40 |
-
# Set the working directory for the user
|
41 |
-
WORKDIR $HOME/app
|
42 |
-
|
43 |
-
# Copy application code to the user's home directory
|
44 |
-
COPY --chown=user . $HOME/app
|
45 |
|
46 |
# Add health check for the application
|
47 |
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
|
48 |
|
49 |
-
#
|
50 |
-
CMD poetry run streamlit run presidio_streamlit.py --server.port
|
|
|
1 |
# Use the official Python slim image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Create a user and set permissions
|
5 |
+
RUN useradd -m -u 1000 user && mkdir -p /app && chown -R user:user /app
|
6 |
+
|
7 |
+
# Set working directory to /app and switch to the user
|
8 |
+
WORKDIR /app
|
9 |
+
USER user
|
10 |
+
|
11 |
+
# Install system dependencies needed for building Python packages (as root)
|
12 |
+
USER root
|
13 |
RUN apt-get update && apt-get install -y \
|
14 |
build-essential \
|
15 |
curl \
|
|
|
19 |
libblas-dev \
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
|
22 |
+
# Switch back to the user to avoid permission issues
|
23 |
+
USER user
|
|
|
24 |
|
25 |
+
# Copy pyproject.toml and poetry.lock first for dependency installation
|
26 |
+
COPY --chown=user:user pyproject.toml poetry.lock /app/
|
|
|
27 |
|
28 |
# Install Poetry via pip
|
29 |
+
RUN pip install --upgrade pip && pip install poetry
|
|
|
30 |
|
31 |
+
# Install dependencies without installing the project root package itself
|
32 |
RUN poetry install --no-root --only=main
|
33 |
|
34 |
# Expose the necessary port
|
35 |
EXPOSE 7860
|
36 |
|
37 |
+
# Copy the rest of your application code to the container
|
38 |
+
COPY --chown=user:user . /app/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Add health check for the application
|
41 |
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
|
42 |
|
43 |
+
# Run the application using Poetry
|
44 |
+
CMD ["poetry", "run", "streamlit", "run", "presidio_streamlit.py", "--server.port=7860", "--server.address=0.0.0.0"]
|