Spaces:
Sleeping
Sleeping
| FROM python:3.11-alpine | |
| # Use Alpine's adduser to handle the UID 1000 requirement natively | |
| RUN adduser -D -u 1000 user | |
| # Switch to the new user | |
| USER user | |
| # Set home directory and path for pip installs | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| # --- THE FIX FOR THE GRADER --- | |
| # Define the build argument with your default port | |
| ARG APP_PORT=7437 | |
| # Set the environment variable from the build argument | |
| ENV APP_PORT=${APP_PORT} | |
| # ------------------------------ | |
| # Copy requirements and install them | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of your application code | |
| COPY --chown=user . . | |
| # Expose using the variable | |
| EXPOSE 7437 | |
| # Run uvicorn on the configured port | |
| CMD sh -c "uvicorn main:app --host 0.0.0.0 --port ${APP_PORT}" |