File size: 1,508 Bytes
c1137be
4ae2d87
8059bbb
c1137be
8059bbb
 
c1137be
8059bbb
 
c1137be
ff6eb07
ffccc46
c1137be
09a22b0
 
ff6eb07
 
 
 
 
 
 
 
 
 
 
 
9636874
ff6eb07
 
 
 
 
30ea85d
 
c1137be
 
6b0c12c
9636874
c1137be
5cb38af
c1137be
 
5cb38af
ff6eb07
 
c1137be
ff6eb07
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
36
37
38
39
40
41
42
43
44
45
46
47
48
# Use the lightweight Python 3.9 image based on Debian Buster
FROM python:3.10-slim-buster

# Set the working directory inside the container
WORKDIR /app

# Copy just the requirements.txt first to leverage Docker cache
COPY requirements.txt .

# Install Python dependencies without storing cache, for a smaller image
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Update package lists and install FFmpeg for media processing
RUN apt-get update && apt-get install -y ffmpeg

RUN useradd -m -u 1000 user

# Switch to root user to change directory ownership
USER root
RUN mkdir -p /usr/share/nltk_data && chown -R user:user /usr/share/nltk_data

USER user
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app

# Set environment variables for NLTK data and Matplotlib configuration
ENV NLTK_DATA /usr/share/nltk_data
ENV MPLCONFIGDIR /tmp/matplotlib

# Create and set permissions for result directories and logs inside the container
# Using a loop can reduce the number of layers and make the Dockerfile cleaner
RUN for dir in results logs; do \
    mkdir $HOME/app/$dir && chmod -R 777 $HOME/app/$dir; \
done

# Copy all Python files from the current directory to the container
COPY *.py .

RUN python setup.py

# Specify the command to run on container start
CMD ["python", "app.py"]