presidio commited on
Commit
3120ac3
1 Parent(s): 478e25a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -36
Dockerfile CHANGED
@@ -1,44 +1,29 @@
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 \
16
- software-properties-common \
17
- libatlas-base-dev \
18
- liblapack-dev \
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"]
 
1
+ # Use the official Python 3.9 image
2
+ FROM python:3.9
3
 
4
+ # Set the working directory to /code
5
+ WORKDIR /code
6
 
7
+ # Copy the current directory contents into the container at /code
8
+ COPY ./pyproject.toml /code/pyproject.toml
9
+ COPY ./poetry.lock /code/poetry.lock
10
+ COPY ./index.md /code/index.md
11
 
12
+ # Install requirements.txt
13
+ RUN pip install poetry && poetry install --only=main
 
 
 
 
 
 
 
 
14
 
15
+ # Set up a new user named "user" with user ID 1000
16
+ RUN useradd -m -u 1000 user
17
+ # Switch to the "user" user
18
  USER user
19
+ # Set home to the user's home directory
20
+ ENV HOME=/home/user \
21
+ PATH=/home/user/.local/bin:$PATH
22
 
23
+ # Set the working directory to the user's home directory
24
+ WORKDIR $HOME/app
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
27
+ COPY --chown=user . $HOME/app
28
 
29
+ CMD ["poetry", "run", "streamlit", "run", "presidio_streamlit.py", "--server.port=7860", "--server.address=0.0.0.0"]