Spaces:
Sleeping
Sleeping
# Use an official Golang runtime as a parent image | |
FROM golang:1.21 | |
# Install necessary dependencies | |
RUN apt-get update && apt-get install -y \ | |
wget \ | |
git \ | |
curl \ | |
zip \ | |
python3 \ | |
python3-venv \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install Katana | |
RUN go install github.com/projectdiscovery/katana/cmd/katana@latest | |
# Set the GOPATH and add Katana to PATH | |
ENV GOPATH=/go | |
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH | |
# Set MPLCONFIGDIR to a writable directory | |
ENV MPLCONFIGDIR=/tmp/.matplotlib | |
# Create a writable directory for Katana's config | |
RUN mkdir -p /tmp/katana | |
# Set the environment variable for Katana's config directory | |
ENV KATANA_CONFIG=/tmp/katana | |
# Create a non-root user | |
RUN useradd -m myuser | |
# Change ownership of the /tmp/katana directory to myuser | |
RUN chown -R myuser:myuser /tmp/katana | |
# Set appropriate permissions | |
RUN chmod 755 /tmp/katana | |
# Create and activate a virtual environment for Python | |
RUN python3 -m venv /app/venv | |
ENV PATH="/app/venv/bin:$PATH" | |
# Copy requirements file | |
COPY requirements.txt /app/requirements.txt | |
# Install Python dependencies in the virtual environment | |
RUN pip install --upgrade pip \ | |
&& pip install -r /app/requirements.txt | |
# Copy the Gradio app code to the container | |
COPY app.py /app/app.py | |
# Set the working directory | |
WORKDIR /app | |
# Switch to the non-root user | |
USER myuser | |
# Expose the port Gradio will run on | |
EXPOSE 7860 | |
# Command to run the Gradio app | |
CMD ["python", "app.py"] | |