Spaces:
Runtime error
Runtime error
| FROM postgres:15 | |
| # Update package list and install Python 3, Pip, and any required packages | |
| FROM ubuntu:20.04 | |
| # Update package list and install Python 3, Pip, and required packages | |
| RUN apt-get update && apt-get install -y python3 python3-pip python3-venv | |
| # Install dependencies for PostgreSQL or Python packages | |
| RUN apt-get install -y libpq-dev gcc | |
| # Create and activate a virtual environment | |
| WORKDIR /app | |
| RUN python3 -m venv venv | |
| ENV PATH="/app/venv/bin:$PATH" | |
| # Copy application files | |
| COPY . /app | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Install Python dependencies inside the virtual environment | |
| RUN pip install --upgrade pip | |
| RUN pip install -r requirements.txt | |
| # Install required packages for PostgreSQL | |
| RUN apt-get update && apt-get install -y \ | |
| # postgresql \ | |
| # postgresql-contrib \ | |
| # && rm -rf /var/lib/apt/lists/* | |
| # Set environment variables for PostgreSQL | |
| ENV POSTGRES_USER="admin" | |
| ENV POSTGRES_PASSWORD="admin" | |
| ENV POSTGRES_DB="admin" | |
| # Expose the PostgreSQL port | |
| EXPOSE 5432 | |
| # Install any necessary dependencies | |
| # RUN pip install -r requirements.txt | |
| # Initialize PostgreSQL database and start the service | |
| # Initialize PostgreSQL database and start the service | |
| # Set environment variables for database name, username, and password | |
| # Optional: If you want to initialize the database with a script | |
| COPY init.sql /docker-entrypoint-initdb.d/ | |
| # Expose PostgreSQL default port | |
| EXPOSE 5432 | |
| EXPOSE 7860 | |
| # Command to run the application along with PostgreSQL | |
| CMD service postgresql start | |
| ENTRYPOINT ["python3", "app.py"] | |
| Use the official Python image as a base image | |
| FROM python:3.8-slim | |
| Set environment variables | |
| ENV FLASK_APP=app.py | |
| ENV FLASK_RUN_HOST=0.0.0.0 | |
| Set the working directory in the container | |
| WORKDIR /app | |
| Copy the requirements file into the container | |
| COPY requirements.txt . | |
| Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| Copy the rest of the application code into the container | |
| COPY . . | |
| Expose the port the app runs on | |
| EXPOSE 7860 | |
| Start the Flask application | |
| CMD ["flask", "run"] | |