Spaces:
Running
Running
File size: 1,144 Bytes
cb91f96 9ebada4 cb91f96 9ebada4 cb91f96 405324c cb91f96 9ebada4 |
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 |
FROM python:3.11
# Required for Hugging Face Spaces Dev Mode to be functional
RUN useradd -m -u 1000 user
WORKDIR /app
# Copy requirements.txt first for better caching
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
RUN pip install flask
# Copy current directory files
COPY . .
# Create a simple health check server
RUN echo 'import flask\nimport os\nimport subprocess\nimport threading\n\napp = flask.Flask(__name__)\n\n@app.route("/")\ndef health():\n return "Voice Assistant running!"\n\ndef run_assistant():\n subprocess.run(["python", "app.py", "dev"])\n\nif __name__ == "__main__":\n # Start the assistant in a separate thread\n assistant_thread = threading.Thread(target=run_assistant)\n assistant_thread.daemon = True\n assistant_thread.start()\n # Run the Flask app for health checks\n app.run(host="0.0.0.0", port=7860)\n' > health_check.py
# Set up user permissions
USER user
# Set home to the user's home directory
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Run the health check server which will start the app
CMD ["python", "health_check.py"] |