insta-agent / Dockerfile
btrabucco's picture
Create Dockerfile
2827569 verified
# Base image to run Playwright
FROM mcr.microsoft.com/playwright:v1.50.1
SHELL ["/bin/bash", "-c"]
# Add conda to the path
ENV PATH="/miniconda3/bin:${PATH}"
ARG PATH="/miniconda3/bin:${PATH}"
ENV CODE_URL="http://github.com/brandontrabucco/insta-dev"
# Install wget to fetch Miniconda
RUN apt-get update && \
apt-get install -y wget git screen htop build-essential ffmpeg && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install Miniconda on x86 or ARM platforms
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
# Clone the repo https://github.com/data-for-agents/insta
RUN git clone $CODE_URL /code/insta
RUN chmod -R 777 /code/insta
RUN chmod -R 777 /miniconda3
# Install the requirements
RUN source /miniconda3/bin/activate && \
conda create -n insta python=3.10 -y && \
conda activate insta && \
pip install -e /code/insta && \
pip install git+https://github.com/huggingface/transformers
# Create a user for the Huggingface space
RUN groupmod -g 1010 ubuntu && \
usermod -u 1010 -g 1010 ubuntu
RUN useradd -m -u 1000 user
# Allow npm to run in the user's home directory
RUN mkdir -p "/home/user/.npm"
RUN chown -R 1000:1000 "/home/user/.npm"
RUN chmod -R 777 /usr/lib
# Allow huggingface to access the user's cache directory
RUN mkdir -p "/home/user/.cache"
RUN chown -R 1000:1000 "/home/user/.cache"
# Set the working directory
WORKDIR /code/insta
USER user
# Set the user environment
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
ENV PATH="/miniconda3/bin:${PATH}"
ARG PATH="/miniconda3/bin:${PATH}"
# Compile the Playwright server
RUN pushd /code/insta/javascript/server && \
rm -rf node_modules package-lock.json && \
npm cache clean --force && \
npm install && npx tsc && \
npx playwright install chromium && popd
# Expose the Playwright server ports
ENV SERVER_BASE_PORT=3000
ENV SERVER_WORKERS=8
# Expose Gradio and Playwright ports
EXPOSE 7860 3000-3007
ENV GRADIO_SERVER_NAME="0.0.0.0"
# Start the Huggingface demo
CMD ["bash", "gradio/start_agent.sh"]