Spaces:
Paused
Paused
Create Dockerfile
Browse files- Dockerfile +71 -0
Dockerfile
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Base image to run Playwright
|
| 2 |
+
FROM mcr.microsoft.com/playwright:v1.50.1
|
| 3 |
+
SHELL ["/bin/bash", "-c"]
|
| 4 |
+
|
| 5 |
+
# Add conda to the path
|
| 6 |
+
ENV PATH="/miniconda3/bin:${PATH}"
|
| 7 |
+
ARG PATH="/miniconda3/bin:${PATH}"
|
| 8 |
+
|
| 9 |
+
ENV CODE_URL="http://github.com/brandontrabucco/insta-dev"
|
| 10 |
+
|
| 11 |
+
# Install wget to fetch Miniconda
|
| 12 |
+
RUN apt-get update && \
|
| 13 |
+
apt-get install -y wget git screen htop build-essential ffmpeg && \
|
| 14 |
+
apt-get clean && \
|
| 15 |
+
rm -rf /var/lib/apt/lists/*
|
| 16 |
+
|
| 17 |
+
# Install Miniconda on x86 or ARM platforms
|
| 18 |
+
RUN arch=$(uname -m) && if [ "$arch" = "x86_64" ]; then MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"; elif [ "$arch" = "aarch64" ]; then MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh"; else echo "Unsupported architecture: $arch"; exit 1; fi && wget $MINICONDA_URL -O miniconda.sh && mkdir -p /home/user/.conda && bash miniconda.sh -b -p /miniconda3 && rm -f miniconda.sh
|
| 19 |
+
|
| 20 |
+
# Clone the repo https://github.com/data-for-agents/insta
|
| 21 |
+
RUN git clone $CODE_URL /code/insta
|
| 22 |
+
RUN chmod -R 777 /code/insta
|
| 23 |
+
RUN chmod -R 777 /miniconda3
|
| 24 |
+
|
| 25 |
+
# Install the requirements
|
| 26 |
+
RUN source /miniconda3/bin/activate && \
|
| 27 |
+
conda create -n insta python=3.10 -y && \
|
| 28 |
+
conda activate insta && \
|
| 29 |
+
pip install -e /code/insta && \
|
| 30 |
+
pip install git+https://github.com/huggingface/transformers
|
| 31 |
+
|
| 32 |
+
# Create a user for the Huggingface space
|
| 33 |
+
RUN groupmod -g 1010 ubuntu && \
|
| 34 |
+
usermod -u 1010 -g 1010 ubuntu
|
| 35 |
+
RUN useradd -m -u 1000 user
|
| 36 |
+
|
| 37 |
+
# Allow npm to run in the user's home directory
|
| 38 |
+
RUN mkdir -p "/home/user/.npm"
|
| 39 |
+
RUN chown -R 1000:1000 "/home/user/.npm"
|
| 40 |
+
RUN chmod -R 777 /usr/lib
|
| 41 |
+
|
| 42 |
+
# Allow huggingface to access the user's cache directory
|
| 43 |
+
RUN mkdir -p "/home/user/.cache"
|
| 44 |
+
RUN chown -R 1000:1000 "/home/user/.cache"
|
| 45 |
+
|
| 46 |
+
# Set the working directory
|
| 47 |
+
WORKDIR /code/insta
|
| 48 |
+
USER user
|
| 49 |
+
|
| 50 |
+
# Set the user environment
|
| 51 |
+
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
|
| 52 |
+
ENV PATH="/miniconda3/bin:${PATH}"
|
| 53 |
+
ARG PATH="/miniconda3/bin:${PATH}"
|
| 54 |
+
|
| 55 |
+
# Compile the Playwright server
|
| 56 |
+
RUN pushd /code/insta/javascript/server && \
|
| 57 |
+
rm -rf node_modules package-lock.json && \
|
| 58 |
+
npm cache clean --force && \
|
| 59 |
+
npm install && npx tsc && \
|
| 60 |
+
npx playwright install chromium && popd
|
| 61 |
+
|
| 62 |
+
# Expose the Playwright server ports
|
| 63 |
+
ENV SERVER_BASE_PORT=3000
|
| 64 |
+
ENV SERVER_WORKERS=8
|
| 65 |
+
|
| 66 |
+
# Expose Gradio and Playwright ports
|
| 67 |
+
EXPOSE 7860 3000-3007
|
| 68 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 69 |
+
|
| 70 |
+
# Start the Huggingface demo
|
| 71 |
+
CMD ["bash", "gradio/start_agent.sh"]
|