Skip to content

Add Dockerfile and README.md instructions #54

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<your-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=<your-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).
Expand Down