diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..7cbb9224 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,40 @@ +/dev-helpers +/docs +/swagger-ui-dist-package +/tests +/.mypy_cache +/design +/docs-build +/assets +/examples +/site +.env +.flake8 +mkdocs.yml + +# Ignore Python cache and bytecode files +**/__pycache__/ +*.pyc +*.pyo +*.pyd + +# Ignore Docker-related files +Dockerfile +.dockerignore + +# Ignore version control directories and files +.git/ +.gitignore +.gitattributes +.github + +# Ignore IDE and editor-specific files +.idea/ +.vscode/ +*.iml + +# Ignore build and dependency files +dist/ +build/ +*.egg-info/ +node_modules/ \ No newline at end of file diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 75c64236..1f23dc02 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -54,6 +54,8 @@ jobs: # https://github.community/t/how-do-i-specify-job-dependency-running-in-another-workflow/16482 if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):') && !contains(github.event.head_commit.message, '[skip release]') runs-on: ubuntu-latest + env: + E2B_ACCESS_TOKEN: ${{ secrets.E2B_ACCESS_TOKEN }} steps: - uses: actions/setup-python@v4 with: @@ -84,3 +86,13 @@ jobs: run: | poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} poetry publish --build -vvv + - name: Setup Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.14.0 + - name: Install e2b CLI + run: npm install -g @e2b/cli@latest + - name: E2B Login + run: e2b auth login + - name: E2B Publish Sandbox Template + e2b template build -d e2b/e2b.Dockerfile -c "/root/.jupyter/start-up.sh" --cpu-count 2 --memory-mb 1024 \ No newline at end of file diff --git a/e2b.toml b/e2b.toml new file mode 100644 index 00000000..e14e6ed7 --- /dev/null +++ b/e2b.toml @@ -0,0 +1,17 @@ +# This is a config for E2B sandbox template. +# You can use 'template_id' (nh8girnufdutxd6xvy00) or 'template_name (va-sandbox) from this config to spawn a sandbox: + +# Python SDK +# from e2b import Sandbox +# sandbox = Sandbox(template='va-sandbox') + +# JS SDK +# import { Sandbox } from 'e2b' +# const sandbox = await Sandbox.create({ template: 'va-sandbox' }) + +template_id = "nh8girnufdutxd6xvy00" +dockerfile = "e2b/e2b.Dockerfile" +template_name = "va-sandbox" +start_cmd = "/root/.jupyter/start-up.sh" +cpu_count = 2 +memory_mb = 1_024 diff --git a/e2b/README.md b/e2b/README.md new file mode 100644 index 00000000..e793512a --- /dev/null +++ b/e2b/README.md @@ -0,0 +1,5 @@ +## Build and push image to e2b: + +```bash +e2b template build -d e2b/e2b.Dockerfile -c "/root/.jupyter/start-up.sh" --cpu-count 2 --memory-mb 1024 +``` diff --git a/e2b/e2b.Dockerfile b/e2b/e2b.Dockerfile new file mode 100644 index 00000000..3b6850e6 --- /dev/null +++ b/e2b/e2b.Dockerfile @@ -0,0 +1,25 @@ +FROM e2bdev/code-interpreter:latest +ENV POETRY_HOME="/opt/poetry" +ENV PATH="$POETRY_HOME/bin:$PATH" +# Disable virtualenv creation for convenience +ENV POETRY_VIRTUALENVS_CREATE=false +# Check if startup_script.sh exists and modify it +RUN if [ -f /root/.jupyter/start-up.sh ]; then \ + sed -i '2i export PYTHONPATH=/home/user/app' /root/.jupyter/start-up.sh; \ + else \ + echo "Error: startup_script.sh does not exist" >&2; \ + exit 1; \ + fi +# Install system dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + curl ffmpeg vim build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Install Poetry and Python dependencies +RUN curl -sSL https://install.python-poetry.org | python - +WORKDIR /home/user/app +# Copy only the dependencies definition to leverage Docker cache +COPY pyproject.toml poetry.lock /home/user/app/ +RUN poetry install --no-root --no-interaction --without dev +COPY . /home/user/app