ZennyKenny commited on
Commit
643d889
·
verified ·
1 Parent(s): f376d1d

Create Dockerfile.txt

Browse files
Files changed (1) hide show
  1. Dockerfile.txt +31 -0
Dockerfile.txt ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.11 as base image
2
+ FROM python:3.11-slim
3
+ # Set working directory
4
+ WORKDIR /code
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ build-essential \
8
+ curl \
9
+ git \
10
+ && rm -rf /var/lib/apt/lists/*
11
+ # Copy requirements first for better caching
12
+ COPY ./requirements.txt /code/requirements.txt
13
+ # Install Python dependencies
14
+ RUN pip install --no-cache-dir -U -r /code/requirements.txt
15
+ # Create a non-root user first
16
+ RUN useradd -m -u 1000 user
17
+ # Switch to non-root 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
+ # Set the working directory to the user's home directory
23
+ WORKDIR $HOME/app
24
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
25
+ COPY --chown=user . $HOME/app
26
+ # Expose port
27
+ EXPOSE 7860
28
+ # Health check
29
+ HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
30
+ # Run the application
31
+ CMD ["python", "app.py"]