File size: 813 Bytes
89f8667
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.9

WORKDIR /app

# Copy and install Python requirements
COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
RUN python -m spacy download en_core_web_sm

# Copy application files
COPY . .


# Add a non-root user and adjust permissions
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \

    && chown -R user:user /app

# Ensure the sudo package is installed
RUN apt-get update && apt-get install -y sudo \

    && echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user \
    && chmod 440 /etc/sudoers.d/90-user

# Set up cache directory for the non-root user
RUN mkdir /.cache && chown user:user /.cache

# Switch to the non-root user
USER user

# Default command
CMD ["python", "main.py"]