Spaces:
Build error
Build error
| # Builder stage | |
| FROM python:3.10-slim as builder | |
| WORKDIR /build | |
| # Install git | |
| RUN apt-get update && \ | |
| apt-get install -y git && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Arguments for secrets | |
| ARG git_usr | |
| ARG TSFtk | |
| ARG private_repo | |
| # Clone the private repository using secrets | |
| RUN --mount=type=secret,id=git_usr,mode=0444,required=true \ | |
| --mount=type=secret,id=TSFtk,mode=0444,required=true \ | |
| --mount=type=secret,id=private_repo,mode=0444,required=true \ | |
| git clone https://$(cat /run/secrets/git_usr):$(cat /run/secrets/TSFtk)@github.com/$(cat /run/secrets/git_usr)/$(cat /run/secrets/private_repo) . | |
| RUN ls -la | |
| # Final stage | |
| FROM python:3.10-slim | |
| # Install git in the final image | |
| RUN apt-get update && \ | |
| apt-get install -y git && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Add user and set up environment | |
| RUN useradd -m vnstock | |
| USER vnstock | |
| WORKDIR /usr/src/app | |
| # Copy the cloned repository from the builder stage | |
| COPY --from=builder /build/private_repo . | |
| RUN ls -la | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Install additional Python packages | |
| RUN pip install --no-cache-dir flask-jwt-extended flask-security | |
| # Set PATH environment variable | |
| ENV PATH="/home/vnstock/.local/bin:${PATH}" | |
| # Expose the application port | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"] |