From 7adca6bd91a44fc25c48be835cf679df3ee135d2 Mon Sep 17 00:00:00 2001 From: aadi Date: Fri, 17 Oct 2025 16:44:15 +0530 Subject: [PATCH] feat: add Docker support with multi-stage build - Add Dockerfile with Ubuntu 24.04 builder and runtime stages - Add .dockerignore to optimize build context - Update README.md with Docker quick start section --- .dockerignore | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 46 +++++++++++++++++++++++++++++++++++++++++ README.md | 16 +++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..02f1198 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,57 @@ +.git/ +.gitignore +.gitattributes + +Dockerfile +.dockerignore + +*.md +!BUILD.md +docs/ +README.md +CONTRIBUTING.md + + +bazel-* +bazel-bin/ +bazel-out/ +bazel-testlogs/ +bazel-workspace/ + + +.vscode/ +.idea/ +*.swp +*.swo +*~ +.DS_Store + +.github/ +.travis.yml +.circleci/ + +scripts/ + +*.tmp +*.log +*.cache +tmp/ +temp/ + + +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +venv/ +env/ +ENV/ +.venv/ + + +node_modules/ + + +Thumbs.db +Desktop.ini diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..25124e6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +# Build stage +FROM ubuntu:24.04 AS builder + +ENV DEBIAN_FRONTEND=noninteractive + +# Install dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + clang \ + git \ + curl \ + python3 \ + python3-pip \ + nodejs \ + npm \ + && rm -rf /var/lib/apt/lists/* + +# Install Bazelisk +RUN npm install -g @bazel/bazelisk + +# Set working directory +WORKDIR /workspace + +# Copy source files +COPY . . + +# Build JSIR +RUN bazelisk build //maldoca/js/ir:jsir_gen + +# Runtime stage +FROM ubuntu:24.04 + +RUN apt-get update && apt-get install -y \ + libstdc++6 \ + python3 \ + && rm -rf /var/lib/apt/lists/* + +# Copy binary from builder +COPY --from=builder /workspace/bazel-bin/maldoca/js/ir/jsir_gen /usr/local/bin/jsir_gen + +# Copy examples +COPY --from=builder /workspace/maldoca/js/ir/conversion/tests /examples + +WORKDIR /workspace + +CMD ["/bin/bash"] diff --git a/README.md b/README.md index 81e18b5..729a122 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,22 @@ for details. ## Getting started +### Docker (Recommended) + +The easiest way to get started with JSIR is using Docker: + +```shell +# Build the Docker image +docker build -t jsir:latest . + +# Run jsir_gen +docker run --rm jsir:latest jsir_gen --help + +# Analyze a JavaScript file +docker run --rm -v $(pwd):/workspace jsir:latest jsir_gen --input_file=/workspace/yourfile.js +``` + + ### Install build tools We have only tested `clang` on Linux: