-
Notifications
You must be signed in to change notification settings - Fork 71
Add sandbox dockerfile generator script #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
25371db
add and move generate_sandbox_dockerfile script to scripts dir
ebae3c6
move generate_enml_project.py to scripts dir
8104d8e
update function to set project name in Dockerfile to base name, and n…
99ba784
generate Dockerfile for oncoclear as an example
398c4e4
update docker parent image to zenmldocker/zenml-sandbox
bfd8c23
use complete env variable key in template
4938493
update dockerfile generator script to use uv, handle pyproject.toml, …
b1ebc93
add tomli to pyproject.toml to parse toml files
434f7cb
generate updated Dockerfile.sandbox for omnireader
6d568df
update script to not generate a .env file if it didnt exist, and dont…
ec8f24e
use uv binary from distroless Docker image instead of installing uv v…
8ff3b48
generate updated Dockerfile.sandbox files
ce252c3
change base image name to zenmldocker/zenml-projects:base
aa062eb
Merge branch 'main' into add-sandbox-dockerfile-generator-script
strickvl b932f3e
add workflow file
f22584c
rename sandbox to codespace
22ebb93
delete generate_zenml_project.py
ed92bdb
revert base image name to zenmldocker/zenml-sandbox
5020fa9
bump python version in pyproject.toml and replace tomli with tomlib
fd25eb0
Use UTC timestamp as Docker image tag in GH action workflow
7f9911e
split workflow into encapsulated jobs to avoid redundant dockerfile_e…
480bffd
update run command to use updated script name and path
761af1d
rename filename: sandbox -> codespace
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| name: Build and Push Project Sandbox Images | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - "_assets/**" | ||
| - ".github/**" | ||
| - ".gitignore" | ||
| - ".gitmodules" | ||
| - ".typos.toml" | ||
| - "CODE-OF-CONDUCT.md" | ||
| - "CONTRIBUTING.md" | ||
| - "scripts/**" | ||
| - "LICENSE" | ||
| - "pyproject.toml" | ||
| - "README.md" | ||
|
|
||
| workflow_dispatch: | ||
| inputs: | ||
| project: | ||
| description: "Project to build (leave empty to detect from changed files)" | ||
| required: false | ||
| default: "" | ||
|
|
||
| jobs: | ||
| detect-changes: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 2 | ||
|
|
||
| - name: Detect changed projects | ||
| id: set-matrix | ||
| run: | | ||
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | ||
| if [ -n "${{ github.event.inputs.project }}" ]; then | ||
| PROJECTS="[\"${{ github.event.inputs.project }}\"]" | ||
| else | ||
| # Auto-detect changed files (same logic as push events) | ||
| CHANGED_FILES=$(git diff --name-only HEAD^ HEAD) | ||
| CHANGED_DIRS=$(echo "$CHANGED_FILES" | grep -o "^[^/]*" | sort -u | grep -v "^$") | ||
| ALL_PROJECT_DIRS=$(find . -maxdepth 1 -type d -not -path "*/\.*" -not -path "." | sed 's|^\./||' | grep -v "^_") | ||
| PROJECTS="[" | ||
| COMMA="" | ||
| for DIR in $CHANGED_DIRS; do | ||
| if echo "$ALL_PROJECT_DIRS" | grep -q "^$DIR$"; then | ||
| PROJECTS="${PROJECTS}${COMMA}\"${DIR}\"" | ||
| COMMA="," | ||
| fi | ||
| done | ||
| PROJECTS="${PROJECTS}]" | ||
| fi | ||
| else | ||
| CHANGED_FILES=$(git diff --name-only HEAD^ HEAD) | ||
| CHANGED_DIRS=$(echo "$CHANGED_FILES" | grep -o "^[^/]*" | sort -u | grep -v "^$") | ||
| ALL_PROJECT_DIRS=$(find . -maxdepth 1 -type d -not -path "*/\.*" -not -path "." | sed 's|^\./||' | grep -v "^_") | ||
| PROJECTS="[" | ||
| COMMA="" | ||
| for DIR in $CHANGED_DIRS; do | ||
| if echo "$ALL_PROJECT_DIRS" | grep -q "^$DIR$"; then | ||
| PROJECTS="${PROJECTS}${COMMA}\"${DIR}\"" | ||
| COMMA="," | ||
| fi | ||
| done | ||
| PROJECTS="${PROJECTS}]" | ||
| fi | ||
| echo "matrix=$PROJECTS" >> $GITHUB_OUTPUT | ||
| echo "Projects to build: $PROJECTS" | ||
|
|
||
| build-and-push: | ||
| needs: detect-changes | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| project: ${{ fromJson(needs.detect-changes.outputs.matrix) }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check for Dockerfile.codespace | ||
| id: check-dockerfile | ||
| run: | | ||
| if [ -f "${{ matrix.project }}/Dockerfile.codespace" ]; then | ||
| echo "dockerfile_exists=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "dockerfile_exists=false" >> $GITHUB_OUTPUT | ||
| echo "No Dockerfile.codespace found in ${{ matrix.project }}, will generate one." | ||
| fi | ||
|
|
||
| - name: Set up Python | ||
| if: steps.check-dockerfile.outputs.dockerfile_exists == 'false' | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: "3.10" | ||
|
|
||
| - name: Generate Dockerfile.codespace if needed | ||
| if: steps.check-dockerfile.outputs.dockerfile_exists == 'false' | ||
| id: generate-dockerfile | ||
| run: | | ||
| python generate_sandbox_dockerfile.py "${{ matrix.project }}" | ||
| echo "Generated Dockerfile.codespace for ${{ matrix.project }}" | ||
|
|
||
| - name: Create Pull Request for new Dockerfile | ||
| if: steps.check-dockerfile.outputs.dockerfile_exists == 'false' | ||
| uses: peter-evans/create-pull-request@v5 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| commit-message: "Auto-generate Dockerfile.codespace for ${{ matrix.project }}" | ||
| title: "Auto-generate Dockerfile.codespace for ${{ matrix.project }}" | ||
| body: | | ||
| This PR adds a generated Dockerfile.codespace for the ${{ matrix.project }} project. | ||
|
|
||
| Please review the changes and merge if they look good. | ||
|
|
||
| Once merged, the Docker image will be built and pushed automatically. | ||
| branch: "auto-dockerfile-${{ matrix.project }}" | ||
| base: main | ||
| labels: | | ||
| automated-pr | ||
| dockerfile | ||
| sandbox | ||
|
|
||
| # Only build and push if Dockerfile already exists | ||
| - name: Set up Docker Buildx | ||
| if: steps.check-dockerfile.outputs.dockerfile_exists == 'true' | ||
| uses: docker/setup-buildx-action@v2 | ||
|
|
||
| - name: Login to DockerHub | ||
| if: steps.check-dockerfile.outputs.dockerfile_exists == 'true' | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
|
||
| - name: Build and push | ||
| if: steps.check-dockerfile.outputs.dockerfile_exists == 'true' | ||
| uses: docker/build-push-action@v4 | ||
| with: | ||
| context: . | ||
| file: ${{ matrix.project }}/Dockerfile.codespace | ||
| push: true | ||
| tags: | | ||
| zenmldocker/projects-${{ matrix.project }}:latest | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Sandbox base image | ||
| FROM zenmldocker/zenml-projects:base | ||
|
|
||
| # Install uv from official distroless image | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
|
|
||
| # Set uv environment variables for optimization | ||
| ENV UV_SYSTEM_PYTHON=1 | ||
| ENV UV_COMPILE_BYTECODE=1 | ||
|
|
||
| # Project metadata | ||
| LABEL project_name="omni-reader" | ||
| LABEL project_version="0.1.0" | ||
|
|
||
| # Install dependencies with uv and cache optimization | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| uv pip install --system \ | ||
| "instructor" \ | ||
| "jiwer" \ | ||
| "jiter" \ | ||
| "importlib-metadata<7.0,>=1.4.0" \ | ||
| "litellm" \ | ||
| "mistralai==1.0.3" \ | ||
| "numpy<2.0,>=1.9.0" \ | ||
| "openai==1.69.0" \ | ||
| "Pillow==11.1.0" \ | ||
| "polars-lts-cpu==1.26.0" \ | ||
| "pyarrow>=7.0.0" \ | ||
| "python-dotenv" \ | ||
| "streamlit==1.44.0" \ | ||
| "pydantic>=2.8.2,<2.9.0" \ | ||
| "tqdm==4.66.4" \ | ||
| "zenml>=0.80.0" | ||
|
|
||
| # Set workspace directory | ||
| WORKDIR /workspace | ||
|
|
||
| # Clone only the project directory and reorganize | ||
| RUN git clone --depth 1 https://github.com/zenml-io/zenml-projects.git /tmp/zenml-projects && \ | ||
| cp -r /tmp/zenml-projects/omni-reader/* /workspace/ && \ | ||
| rm -rf /tmp/zenml-projects | ||
|
|
||
| # VSCode settings | ||
| RUN mkdir -p /workspace/.vscode && \ | ||
| printf '{\n "workbench.colorTheme": "Default Dark Modern"\n}' > /workspace/.vscode/settings.json | ||
|
|
||
| # Copy .env.example | ||
| COPY .env.example /workspace/.env | ||
| ENV POLARS_SKIP_CPU_CHECK=1 |
marwan37 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.