diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e8d8556 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +FROM python:3.12-alpine AS builder +# Executable application name +ARG APP_NAME=code2tutorials + +LABEL org.opencontainers.image.authors="samin-irtiza" \ + org.opencontainers.image.title="${APP_NAME} Builder" \ + org.opencontainers.image.description="Build layer for the ${APP_NAME} application, which generates tutorials from codebases." \ + org.opencontainers.image.version="1.0" \ + org.opencontainers.image.source="https://github.com/The-Pocket/Tutorial-Codebase-Knowledge" + +ENV PYTHONUNBUFFERED=1 \ + PIP_NO_CACHE_DIR=1 + +WORKDIR /app + +COPY requirements.txt /app/ + +RUN apk add --no-cache git patchelf binutils && \ + pip install --upgrade pip && \ + pip install -r requirements.txt && \ + pip install pyinstaller + +COPY . /app + +RUN pyinstaller --onefile --name $APP_NAME main.py + +FROM alpine:latest +# Executable application name +ARG APP_NAME=code2tutorials +LABEL org.opencontainers.image.authors="samin-irtiza" \ + org.opencontainers.image.title="${APP_NAME}" \ + org.opencontainers.image.description="Runtime layer for the ${APP_NAME} application, a CLI tool for generating tutorials from codebases." \ + org.opencontainers.image.version="1.0" \ + org.opencontainers.image.source="https://github.com/The-Pocket/Tutorial-Codebase-Knowledge" + +WORKDIR /app + +COPY --from=builder /app/dist /app/ + +RUN apk add --no-cache git + +RUN chmod +x /app/$APP_NAME + +# Change the entrypoint according to the executable application name. +ENTRYPOINT ["/app/code2tutorials"] +CMD ["--help"] \ No newline at end of file diff --git a/README.md b/README.md index 2f47179..c206f00 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,31 @@ This is a tutorial project of [Pocket Flow](https://github.com/The-Pocket/Pocket The application will crawl the repository, analyze the codebase structure, generate tutorial content in the specified language, and save the output in the specified directory (default: ./output). + +## 🐳 Run with Docker + +1. Navigate to the root directory of the project and build the Docker image: + ```bash + docker build -t code2tutorials . + ``` + +2. Run the container with the following command: + ```bash + docker run -it --rm \ + -v $(pwd):/app \ + --env GEMINI_API_KEY= \ + code2tutorials --repo https://github.com/username/repo-name + ``` + +3. For easier access, set an alias for the Docker command in your shell configuration file (e.g., `.bashrc` or `.zshrc`): + ```bash + alias code2tutorials='docker run -it --rm -v $(pwd):/app --env GEMINI_API_KEY= code2tutorials' + ``` + +4. After setting the alias, run the application with a simplified command: + ```bash + code2tutorials --repo https://github.com/username/repo-name + ``` ## 💡 Development Tutorial - I built using [**Agentic Coding**](https://zacharyhuang.substack.com/p/agentic-coding-the-most-fun-way-to), the fastest development paradigm, where humans simply [design](docs/design.md) and agents [code](flow.py).