Spaces:
Sleeping
Sleeping
| FROM python:3.11.9-slim | |
| # Expose the secret SECRETS at build-time | |
| RUN --mount=type=secret,id=REDIS_URL,mode=0444,required=true | |
| RUN --mount=type=secret,id=REDIS_USERNAME,mode=0444,required=true | |
| RUN --mount=type=secret,id=REDIS_PASSWORD,mode=0444,required=true | |
| # Read secrets and set environment variables | |
| RUN export REDIS_URL=$(cat /run/secrets/REDIS_URL) \ | |
| && export REDIS_USERNAME=$(cat /run/secrets/REDIS_USERNAME) \ | |
| && export REDIS_PASSWORD=$(cat /run/secrets/REDIS_PASSWORD) \ | |
| && echo "REDIS_URL=$REDIS_URL" >> /etc/environment \ | |
| && echo "REDIS_USERNAME=$REDIS_USERNAME" >> /etc/environment \ | |
| && echo "REDIS_PASSWORD=$REDIS_PASSWORD" >> /etc/environment | |
| # Source the environment file | |
| RUN . /etc/environment | |
| # Copy requirements file | |
| COPY requirements_docker_api.txt . | |
| # Update pip | |
| RUN pip --timeout=30000 install --no-cache-dir --upgrade pip | |
| # Install dependecies | |
| RUN pip --timeout=30000 install --no-cache-dir -r requirements_docker_api.txt | |
| # Copy API | |
| RUN mkdir /src/ | |
| COPY ./src /src | |
| # Set workdir | |
| WORKDIR / | |
| # Expose app port | |
| EXPOSE 7860 | |
| # Start application | |
| CMD ["uvicorn", "src.api.api:app", "--host", "0.0.0.0", "--port", "7860"] |