muhammadnoman76 commited on
Commit
5a868f7
·
1 Parent(s): dde038e
Files changed (2) hide show
  1. Dockerfile +16 -12
  2. entrypoint.sh +21 -8
Dockerfile CHANGED
@@ -5,25 +5,33 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
5
  PYTHONUNBUFFERED=1 \
6
  PIP_NO_CACHE_DIR=1 \
7
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
8
- PORT=7860
 
 
9
 
10
  # Install system dependencies
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
  ffmpeg \
13
  git \
14
- && rm -rf /var/lib/apt/lists/*
 
 
15
 
16
  # Create non-root user (Hugging Face Spaces requirement)
17
  RUN useradd -m -u 1000 user
18
- ENV HOME=/home/user \
19
- PATH=/home/user/.local/bin:$PATH
20
 
21
  # Set work directory
22
- WORKDIR $HOME/app
 
 
 
23
 
24
- # Copy entrypoint script
25
- COPY --chown=user entrypoint.sh $HOME/app/entrypoint.sh
26
- RUN chmod +x $HOME/app/entrypoint.sh
 
 
 
27
 
28
  # Switch to non-root user
29
  USER user
@@ -31,9 +39,5 @@ USER user
31
  # Expose port (Hugging Face uses 7860)
32
  EXPOSE 7860
33
 
34
- # Health check
35
- HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
36
- CMD python -c "import httpx; httpx.get('http://localhost:7860/health')" || exit 1
37
-
38
  # Run entrypoint
39
  CMD ["/home/user/app/entrypoint.sh"]
 
5
  PYTHONUNBUFFERED=1 \
6
  PIP_NO_CACHE_DIR=1 \
7
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
8
+ PORT=7860 \
9
+ HOME=/home/user \
10
+ PATH=/home/user/.local/bin:$PATH
11
 
12
  # Install system dependencies
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  ffmpeg \
15
  git \
16
+ curl \
17
+ && rm -rf /var/lib/apt/lists/* \
18
+ && apt-get clean
19
 
20
  # Create non-root user (Hugging Face Spaces requirement)
21
  RUN useradd -m -u 1000 user
 
 
22
 
23
  # Set work directory
24
+ WORKDIR /home/user/app
25
+
26
+ # Copy entrypoint script first
27
+ COPY --chown=user:user entrypoint.sh /home/user/app/entrypoint.sh
28
 
29
+ # Make entrypoint executable
30
+ RUN chmod +x /home/user/app/entrypoint.sh
31
+
32
+ # Create directories that will be needed
33
+ RUN mkdir -p /home/user/app/langvoice_backend/uploads \
34
+ && chown -R user:user /home/user
35
 
36
  # Switch to non-root user
37
  USER user
 
39
  # Expose port (Hugging Face uses 7860)
40
  EXPOSE 7860
41
 
 
 
 
 
42
  # Run entrypoint
43
  CMD ["/home/user/app/entrypoint.sh"]
entrypoint.sh CHANGED
@@ -1,11 +1,12 @@
1
- #!/bin/bash
2
  set -e
3
 
4
  echo "=========================================="
5
  echo "LangVoice Backend - Hugging Face Deployment"
6
  echo "=========================================="
 
7
 
8
- APP_DIR="$HOME/app"
9
  BACKEND_DIR="$APP_DIR/langvoice_backend"
10
 
11
  # Check if the backend is already set up
@@ -19,24 +20,34 @@ if [ ! -d "$BACKEND_DIR/app" ]; then
19
  exit 1
20
  fi
21
 
 
 
22
  # Clone the langvoice repository
23
  echo "Cloning langvoice repository..."
24
- git clone --depth 1 https://${GITHUB_TOKEN}@github.com/nomanalisyed2/{YOUR_REPO_NAME}.git /tmp/langvoice
 
 
 
25
 
26
  # Copy backend files
27
  echo "Copying backend files..."
28
  mkdir -p "$BACKEND_DIR"
29
  cp -r /tmp/langvoice/langvoice_backend/* "$BACKEND_DIR/"
30
 
31
- # Clean up
32
  rm -rf /tmp/langvoice
33
 
34
  # Install Python dependencies
35
  echo "Installing Python dependencies..."
36
  cd "$BACKEND_DIR"
37
- pip install --user -e .
 
 
 
38
 
 
39
  echo "Setup complete!"
 
40
  else
41
  echo "Backend already set up. Skipping clone..."
42
  fi
@@ -47,13 +58,15 @@ cd "$BACKEND_DIR"
47
  # Create any required directories
48
  mkdir -p uploads
49
 
50
- # Set environment variables for Hugging Face
51
  export HOST="0.0.0.0"
52
  export PORT="${PORT:-7860}"
53
 
54
  echo "=========================================="
55
- echo "Starting LangVoice Backend on port $PORT"
 
 
56
  echo "=========================================="
57
 
58
  # Run the FastAPI application
59
- exec python -m uvicorn app.main:app --host 0.0.0.0 --port $PORT
 
1
+ #!/bin/sh
2
  set -e
3
 
4
  echo "=========================================="
5
  echo "LangVoice Backend - Hugging Face Deployment"
6
  echo "=========================================="
7
+ echo "Starting at: $(date)"
8
 
9
+ APP_DIR="/home/user/app"
10
  BACKEND_DIR="$APP_DIR/langvoice_backend"
11
 
12
  # Check if the backend is already set up
 
20
  exit 1
21
  fi
22
 
23
+ echo "GitHub token found, proceeding with clone..."
24
+
25
  # Clone the langvoice repository
26
  echo "Cloning langvoice repository..."
27
+ git clone --depth 1 "https://${GITHUB_TOKEN}@github.com/LangVoice/langflow.git" /tmp/langvoice || {
28
+ echo "Failed to clone repository. Check GITHUB_TOKEN permissions."
29
+ exit 1
30
+ }
31
 
32
  # Copy backend files
33
  echo "Copying backend files..."
34
  mkdir -p "$BACKEND_DIR"
35
  cp -r /tmp/langvoice/langvoice_backend/* "$BACKEND_DIR/"
36
 
37
+ # Clean up cloned repo
38
  rm -rf /tmp/langvoice
39
 
40
  # Install Python dependencies
41
  echo "Installing Python dependencies..."
42
  cd "$BACKEND_DIR"
43
+ pip install --user --no-cache-dir -e . || {
44
+ echo "Failed to install dependencies"
45
+ exit 1
46
+ }
47
 
48
+ echo "=========================================="
49
  echo "Setup complete!"
50
+ echo "=========================================="
51
  else
52
  echo "Backend already set up. Skipping clone..."
53
  fi
 
58
  # Create any required directories
59
  mkdir -p uploads
60
 
61
+ # Set environment variables
62
  export HOST="0.0.0.0"
63
  export PORT="${PORT:-7860}"
64
 
65
  echo "=========================================="
66
+ echo "Starting LangVoice Backend"
67
+ echo "Host: $HOST"
68
+ echo "Port: $PORT"
69
  echo "=========================================="
70
 
71
  # Run the FastAPI application
72
+ exec python -m uvicorn app.main:app --host "$HOST" --port "$PORT"