amirjamali commited on
Commit
77cd9f4
·
unverified ·
1 Parent(s): 5bacc9d

Refactor Dockerfile for improved readability and maintainability; streamline environment variable and command formatting

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -15
Dockerfile CHANGED
@@ -1,21 +1,21 @@
1
  FROM python:3.9-slim
2
 
3
  # Set environment variables
4
- ENV PYTHONUNBUFFERED=1 `
5
- PYTHONDONTWRITEBYTECODE=1 `
6
  MPLCONFIGDIR=/tmp/matplotlib
7
 
8
  WORKDIR /app
9
 
10
  # Install system dependencies
11
- RUN apt-get update && `
12
- apt-get install -y --no-install-recommends `
13
- build-essential `
14
- curl `
15
- git `
16
- ffmpeg `
17
- libsndfile1 `
18
- && apt-get clean `
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
  # Create necessary directories
@@ -25,17 +25,26 @@ RUN mkdir -p /app/tmp_model /tmp/matplotlib
25
  COPY requirements.txt .
26
 
27
  # Install Python dependencies with specific order for compatibility
28
- RUN pip install --no-cache-dir --upgrade pip && `
29
- pip install --no-cache-dir torch==2.0.1 torchaudio==2.0.2 && `
30
- pip install --no-cache-dir -r requirements.txt && `
31
  pip install --no-cache-dir git+https://github.com/speechbrain/speechbrain.git@v0.5.14
32
 
33
  # Copy source code
34
  COPY src/ ./src/
35
 
36
  # Set up Streamlit configuration
37
- RUN mkdir -p .streamlit && `
38
- echo "[server]`nport = 8501`naddress = \"0.0.0.0\"`nheadless = true`n`n[browser]`ngatherUsageStats = false`n`n[runner]`nfastReruns = true" > ./.streamlit/config.toml
 
 
 
 
 
 
 
 
 
39
 
40
  # Expose port
41
  EXPOSE 8501
 
1
  FROM python:3.9-slim
2
 
3
  # Set environment variables
4
+ ENV PYTHONUNBUFFERED=1 \
5
+ PYTHONDONTWRITEBYTECODE=1 \
6
  MPLCONFIGDIR=/tmp/matplotlib
7
 
8
  WORKDIR /app
9
 
10
  # Install system dependencies
11
+ RUN apt-get update && \
12
+ apt-get install -y --no-install-recommends \
13
+ build-essential \
14
+ curl \
15
+ git \
16
+ ffmpeg \
17
+ libsndfile1 \
18
+ && apt-get clean \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
  # Create necessary directories
 
25
  COPY requirements.txt .
26
 
27
  # Install Python dependencies with specific order for compatibility
28
+ RUN pip install --no-cache-dir --upgrade pip && \
29
+ pip install --no-cache-dir torch==2.0.1 torchaudio==2.0.2 && \
30
+ pip install --no-cache-dir -r requirements.txt && \
31
  pip install --no-cache-dir git+https://github.com/speechbrain/speechbrain.git@v0.5.14
32
 
33
  # Copy source code
34
  COPY src/ ./src/
35
 
36
  # Set up Streamlit configuration
37
+ RUN mkdir -p .streamlit
38
+ RUN echo "[server]" > ./.streamlit/config.toml && \
39
+ echo "port = 8501" >> ./.streamlit/config.toml && \
40
+ echo "address = \"0.0.0.0\"" >> ./.streamlit/config.toml && \
41
+ echo "headless = true" >> ./.streamlit/config.toml && \
42
+ echo "" >> ./.streamlit/config.toml && \
43
+ echo "[browser]" >> ./.streamlit/config.toml && \
44
+ echo "gatherUsageStats = false" >> ./.streamlit/config.toml && \
45
+ echo "" >> ./.streamlit/config.toml && \
46
+ echo "[runner]" >> ./.streamlit/config.toml && \
47
+ echo "fastReruns = true" >> ./.streamlit/config.toml
48
 
49
  # Expose port
50
  EXPOSE 8501