| FROM python:3.10-slim | |
| # Install Node to run Motion Canvas | |
| WORKDIR /tmp/node | |
| RUN apt-get update && apt-get install -y nodejs npm | |
| # without v prefix! | |
| ARG MC_VERSION="3.17.2" | |
| ENV NODE_ENV=$MC_VERSION | |
| WORKDIR /motion-canvas | |
| RUN yes '' | npm init -y @motion-canvas@$MC_VERSION | |
| WORKDIR /motion-canvas/my-animation | |
| ENV MC_PROJECT_DIR=/motion-canvas/my-animation | |
| # copy the vite.config.ts file to the project to get deterministic output filenames under dist/project.js | |
| COPY docker/vite.config.ts ./vite.config.ts | |
| # if we build here, we have to clean up the project every time before building a new one... | |
| RUN npm install | |
| RUN npm run build | |
| # Install Gradio and copy local files | |
| WORKDIR /app | |
| COPY ./requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY . . | |
| RUN mkdir -p /app/public | |
| RUN useradd -m -u 1000 user | |
| RUN chown -R user:user /motion-canvas | |
| RUN chown -R user:user /app | |
| USER user | |
| EXPOSE 7860 | |
| ENV GRADIO_SERVER_NAME="0.0.0.0" | |
| CMD ["python", "app.py"] |