File size: 989 Bytes
ff4f219
cc4f142
6bf6112
 
7bdea2a
6bf6112
e566133
4d957e1
6bf6112
 
8ba973d
6bf6112
 
 
 
 
5b3b248
6bf6112
 
8e35bdc
6bf6112
 
d263103
6bf6112
 
07dc4f3
6bf6112
 
07dc4f3
6bf6112
 
b9dcb4f
6bf6112
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
FROM python:3.11

# Create and use a non-root user
RUN useradd -ms /bin/bash admin

# Set working directory for the application
WORKDIR /app

# Copy only the necessary files first for better cache utilization
COPY requirements.txt /app/requirements.txt

# Install system dependencies and clean up in a single RUN step to reduce layers
RUN apt-get update -y && apt-get upgrade -y \
    && apt-get install -y \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies from the requirements file
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt

# Copy the rest of the application code after installing dependencies for better cache
COPY . /app

# Set ownership and permissions for the app directory
RUN chown -R admin:admin /app && chmod -R 777 /app

# Switch to the non-root user for better security
USER admin

# Expose the port the application will run on
EXPOSE 7860

# Command to run the application
CMD ["python", "-u", "-m", "FileStream"]