ZennyKenny commited on
Commit
ad7506d
·
verified ·
1 Parent(s): b8dce21
Files changed (1) hide show
  1. Dockerfile.txt → Dockerfile +12 -0
Dockerfile.txt → Dockerfile RENAMED
@@ -1,31 +1,43 @@
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"]
 
1
  # Use Python 3.11 as base image
2
  FROM python:3.11-slim
3
+
4
  # Set working directory
5
  WORKDIR /code
6
+
7
  # Install system dependencies
8
  RUN apt-get update && apt-get install -y \
9
  build-essential \
10
  curl \
11
  git \
12
  && rm -rf /var/lib/apt/lists/*
13
+
14
  # Copy requirements first for better caching
15
  COPY ./requirements.txt /code/requirements.txt
16
+
17
  # Install Python dependencies
18
  RUN pip install --no-cache-dir -U -r /code/requirements.txt
19
+
20
  # Create a non-root user first
21
  RUN useradd -m -u 1000 user
22
+
23
  # Switch to non-root user
24
  USER user
25
+
26
  # Set home to the user's home directory
27
  ENV HOME=/home/user \
28
  PATH=/home/user/.local/bin:$PATH
29
+
30
  # Set the working directory to the user's home directory
31
  WORKDIR $HOME/app
32
+
33
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
34
  COPY --chown=user . $HOME/app
35
+
36
  # Expose port
37
  EXPOSE 7860
38
+
39
  # Health check
40
  HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
41
+
42
  # Run the application
43
  CMD ["python", "app.py"]