From 3e86ec99cc7559ed5abfa5b3cd2f94ffd46ce046 Mon Sep 17 00:00:00 2001 From: "Md. Samin Irtiza" <62540152+samin-irtiza@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:58:38 +0600 Subject: [PATCH 1/5] Add Dockerfile --- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d53b14f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM python:3.12-alpine AS builder + +LABEL org.opencontainers.image.authors="samin-irtiza" \ + description="A Dockerfile for building and running the code2docs application" \ + version="1.0" + +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 code2docs main.py + +FROM alpine:latest + +LABEL org.opencontainers.image.authors="samin-irtiza" \ + description="A lightweight runtime image for the code2docs application" \ + version="1.0" + +WORKDIR /app + +COPY --from=builder /app/dist /app/ + +RUN apk add --no-cache git + +RUN chmod +x /app/code2docs + +ENTRYPOINT ["/app/code2docs"] +CMD ["--help"] \ No newline at end of file From 68d36be6f2ff5d8fc53acbaea46a0d6dc91e6831 Mon Sep 17 00:00:00 2001 From: "Md. Samin Irtiza" <62540152+samin-irtiza@users.noreply.github.com> Date: Sat, 26 Apr 2025 03:36:17 +0600 Subject: [PATCH 2/5] Update Dockerfile and README.md instructions for docker. --- Dockerfile | 14 +++++++++----- README.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index d53b14f..e36864a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM python:3.12-alpine AS builder +ARG APP_NAME=code2tutorials LABEL org.opencontainers.image.authors="samin-irtiza" \ - description="A Dockerfile for building and running the code2docs application" \ + description="A Dockerfile for building and running the ${APP_NAME} application" \ version="1.0" ENV PYTHONUNBUFFERED=1 \ @@ -18,12 +19,13 @@ RUN apk add --no-cache git patchelf binutils && \ COPY . /app -RUN pyinstaller --onefile --name code2docs main.py +RUN pyinstaller --onefile --name $APP_NAME main.py FROM alpine:latest +ARG APP_NAME=code2tutorials LABEL org.opencontainers.image.authors="samin-irtiza" \ - description="A lightweight runtime image for the code2docs application" \ + description="A lightweight runtime image for the ${APP_NAME} application" \ version="1.0" WORKDIR /app @@ -32,7 +34,9 @@ COPY --from=builder /app/dist /app/ RUN apk add --no-cache git -RUN chmod +x /app/code2docs +RUN chmod +x /app/$APP_NAME -ENTRYPOINT ["/app/code2docs"] +ENV APP_NAME=${APP_NAME} + +ENTRYPOINT ["/bin/sh", "-c", "/app/$APP_NAME"] CMD ["--help"] \ No newline at end of file diff --git a/README.md b/README.md index 2f47179..615bcfb 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,35 @@ 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 + +You can easily run the application using Docker. Follow these steps: + +1. Build the Docker Image +Navigate to the root directory of the project and build the Docker image: +```bash +docker build -t code2tutorials . +``` + +2. Run the Docker Container +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. Optional: Create a Shell Alias (Linux) +For easier access, you can 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' +``` + +After setting the alias, you can 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). From 34842060fb16a9a684bd7f1612c3f1842f89b3d9 Mon Sep 17 00:00:00 2001 From: "Md. Samin Irtiza" <62540152+samin-irtiza@users.noreply.github.com> Date: Sat, 26 Apr 2025 04:05:12 +0600 Subject: [PATCH 3/5] Update README.md docker instructions --- README.md | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 615bcfb..c206f00 100644 --- a/README.md +++ b/README.md @@ -115,35 +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 -You can easily run the application using Docker. Follow these steps: - -1. Build the Docker Image -Navigate to the root directory of the project and build the Docker image: -```bash -docker build -t code2tutorials . -``` - -2. Run the Docker Container -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. Optional: Create a Shell Alias (Linux) -For easier access, you can 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' -``` - -After setting the alias, you can run the application with a simplified command: -```bash -code2tutorials --repo https://github.com/username/repo-name -``` +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). From 7e04bf0e6e4763cf533306b0096db24f00d7a727 Mon Sep 17 00:00:00 2001 From: "Md. Samin Irtiza" <62540152+samin-irtiza@users.noreply.github.com> Date: Sat, 26 Apr 2025 11:25:56 +0600 Subject: [PATCH 4/5] Fix Entrypoint positional argument passing issue --- Dockerfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index e36864a..330f280 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,10 @@ FROM python:3.12-alpine AS builder ARG APP_NAME=code2tutorials LABEL org.opencontainers.image.authors="samin-irtiza" \ - description="A Dockerfile for building and running the ${APP_NAME} application" \ - version="1.0" + 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 @@ -23,10 +25,11 @@ RUN pyinstaller --onefile --name $APP_NAME main.py FROM alpine:latest ARG APP_NAME=code2tutorials - LABEL org.opencontainers.image.authors="samin-irtiza" \ - description="A lightweight runtime image for the ${APP_NAME} application" \ - version="1.0" + 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 @@ -38,5 +41,5 @@ RUN chmod +x /app/$APP_NAME ENV APP_NAME=${APP_NAME} -ENTRYPOINT ["/bin/sh", "-c", "/app/$APP_NAME"] +ENTRYPOINT ["/bin/sh", "-c", "exec /app/$APP_NAME \"$@\"", "--"] CMD ["--help"] \ No newline at end of file From c0a218d9d0126933b060110e0e1a7ccf04257038 Mon Sep 17 00:00:00 2001 From: "Md. Samin Irtiza" <62540152+samin-irtiza@users.noreply.github.com> Date: Sat, 26 Apr 2025 12:00:49 +0600 Subject: [PATCH 5/5] Update Dockerfile Entrypoint --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 330f280..e8d8556 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM python:3.12-alpine AS builder +# Executable application name ARG APP_NAME=code2tutorials LABEL org.opencontainers.image.authors="samin-irtiza" \ @@ -24,6 +25,7 @@ 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}" \ @@ -39,7 +41,6 @@ RUN apk add --no-cache git RUN chmod +x /app/$APP_NAME -ENV APP_NAME=${APP_NAME} - -ENTRYPOINT ["/bin/sh", "-c", "exec /app/$APP_NAME \"$@\"", "--"] +# Change the entrypoint according to the executable application name. +ENTRYPOINT ["/app/code2tutorials"] CMD ["--help"] \ No newline at end of file