From cde732c57decc9111de8dd00748a1dec34014538 Mon Sep 17 00:00:00 2001 From: Kirill Markin Date: Mon, 30 Dec 2024 15:58:04 +0100 Subject: [PATCH] docker instructions cleanup --- DOCKER.md | 27 --------------------------- Dockerfile | 30 +++++++++++++++++++++++++----- README.md | 38 ++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 5 ++++- 4 files changed, 67 insertions(+), 33 deletions(-) delete mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md deleted file mode 100644 index a46a36d..0000000 --- a/DOCKER.md +++ /dev/null @@ -1,27 +0,0 @@ -# Docker Usage Instructions - -## Building and Running - -1. Build the container: -```bash -docker-compose build -``` - -2. Start a shell session: -```bash -docker-compose run --rm repo-to-text -``` - -Once in the shell, you can run repo-to-text: -```bash -# Process current directory -repo-to-text - -# Process specific directory -repo-to-text /home/user/myproject - -# Use with options -repo-to-text --output-dir /home/user/output -``` - -The container mounts your home directory at `/home/user`, allowing access to all your projects. diff --git a/Dockerfile b/Dockerfile index c142ab8..8b5cd53 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,33 @@ -FROM python:3.11-slim +FROM python:3.12-slim -RUN apt-get update && apt-get install -y \ - tree \ - && rm -rf /var/lib/apt/lists/* +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 +# Create non-root user RUN useradd -m -s /bin/bash user +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + tree \ + && rm -rf /var/lib/apt/lists/* + WORKDIR /app + +# Copy all necessary files for package installation +COPY pyproject.toml README.md ./ + +# Copy the package source +COPY repo_to_text ./repo_to_text + +# Install the package +RUN pip install --no-cache-dir -e . + +# Copy remaining files COPY . . -RUN pip install -e . && pip install pyperclip + +# Set default user +USER user ENTRYPOINT ["repo-to-text"] diff --git a/README.md b/README.md index 8d8e3e1..3bb60e4 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,44 @@ You can customize the behavior of `repo-to-text` with the following options: This will write the output directly to `myfile.txt` instead of creating a timestamped file. +## Docker Usage + +### Building and Running + +1. Build the container: + + ```bash + docker compose build + ``` + +2. Start a shell session: + + ```bash + docker compose run --rm repo-to-text + ``` + +Once in the shell, you can run `repo-to-text`: + +- Process current directory: + + ```bash + repo-to-text + ``` + +- Process specific directory: + + ```bash + repo-to-text /home/user/myproject + ``` + +- Use with options: + + ```bash + repo-to-text --output-dir /home/user/output + ``` + +The container mounts your home directory at `/home/user`, allowing access to all your projects. + ## Settings `repo-to-text` also supports configuration via a `.repo-to-text-settings.yaml` file. By default, the tool works without this file, but you can use it to customize what gets included in the final text file. diff --git a/docker-compose.yaml b/docker-compose.yaml index 75d0efc..07a8e37 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,10 +1,13 @@ services: repo-to-text: - build: . + build: + context: . + dockerfile: Dockerfile volumes: - ${HOME:-/home/user}:/home/user working_dir: /home/user environment: - HOME=/home/user user: "${UID:-1000}:${GID:-1000}" + init: true entrypoint: ["/bin/bash"]