File size: 1,319 Bytes
fa303b0
 
97e7d36
 
 
 
 
 
 
 
 
 
d6803c0
 
 
 
 
d2e1f69
 
 
 
 
 
 
d6803c0
 
97e7d36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
54
55
56
# Utiliser Python 3.10 comme base
FROM python:3.10-slim

# Installer poetry
RUN pip install poetry

# Create a non-root user
RUN useradd -m -u 1000 appuser

# Définir le répertoire de travail
WORKDIR /app

# Install system dependencies for PyAudio before poetry install
RUN apt-get update && apt-get install -y \
    gcc \
    portaudio19-dev \
    python3-dev \
    libasound2-dev \
    libpulse-dev \
    libportaudio2 \
    libportaudiocpp0 \
    libasound2 \
    libasound2-data \
    wget \
    && rm -rf /var/lib/apt/lists/*

# Copier les fichiers de dépendances
COPY poetry.lock pyproject.toml ./
COPY . .

# Configurer poetry pour ne pas créer un environnement virtuel
RUN poetry config virtualenvs.create false

# Installer les dépendances sans installer le projet lui-même
RUN poetry install --only main --no-interaction --no-ansi --no-root

# Create static directory and set permissions
RUN mkdir -p /app/server/static && \
    chown -R appuser:appuser /app && \
    # Verify the static files are present
    ls -la /app/server/static

# Switch to non-root user
USER appuser

# Verify permissions after user switch
RUN ls -la ~ && \
    mkdir -p ~/static && \
    ls -la ~/static

# Exposer le port utilisé par Flask
EXPOSE 7860

# Commande pour démarrer l'application
CMD ["python", "-m", "server"]