Spaces:
Build error
Build error
File size: 886 Bytes
aa26805 0565e38 aa26805 0565e38 aa26805 | 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 | # Use a base image with Python
FROM python:3.9
# Install MySQL
RUN apt-get update && apt-get install -y mysql-server && apt-get clean
# Set the working directory
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Set environment variables for MySQL
ENV MYSQL_ROOT_PASSWORD=rootpassword
ENV MYSQL_DATABASE=mydatabase
ENV MYSQL_USER=myuser
ENV MYSQL_PASSWORD=mypassword
# Expose port 80 for the FastAPI app and 3306 for MySQL
EXPOSE 7860 3306
# Initialize MySQL and run FastAPI
CMD service mysql start && mysql -e "CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE}; GRANT ALL ON ${MYSQL_DATABASE}.* TO '${MYSQL_USER}'@'localhost' IDENTIFIED BY '${MYSQL_PASSWORD}'; FLUSH PRIVILEGES;" && uvicorn main:app --host 0.0.0.0 --port 7860
|