diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..631a7be --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +.git +.gitignore +__pycache__/ +*.pyc +*.pyo +*.pyd +*.log +.venv/ +venv/ +.env +sync_config.json +sync_mapping.json +tests/ +README.md +LICENSE diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2965513 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM --platform=$TARGETPLATFORM python:3.12-slim-bookworm + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PIP_NO_CACHE_DIR=1 + +WORKDIR /app + +# Install Python dependencies first to leverage layer caching. +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +# Copy application source. +COPY jira_jotty_sync.py ./ +COPY sync_config.json.template ./ + +# Run as non-root for better container security. +RUN useradd --create-home --uid 10001 appuser && chown -R appuser:appuser /app +USER appuser + +ENTRYPOINT ["python", "jira_jotty_sync.py"] +CMD ["--direction", "both"] diff --git a/README.md b/README.md index f860c96..5e5ccc1 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,64 @@ python jira_jotty_sync.py --direction=jotty-to-jira python jira_jotty_sync.py --direction=both ``` +## Docker (Raspberry Pi 5 / ARM64) + +### Build for ARM64 + +On Raspberry Pi 5 (native ARM64): + +```bash +docker build -t jotty-jira-sync:arm64 . +``` + +From another machine using buildx: + +```bash +docker buildx build \ + --platform linux/arm64 \ + -t jotty-jira-sync:arm64 \ + . +``` + +### Prepare runtime config files + +Create local config files in the project folder: + +```bash +cp sync_config.json.template sync_config.json +# Optional if you prefer env-based auth instead of putting secrets in JSON +touch .env +``` + +### Run container + +The container runs `python jira_jotty_sync.py --direction both` by default. + +```bash +docker run --rm \ + --name jotty-jira-sync \ + -v "$(pwd)/sync_config.json:/app/sync_config.json:ro" \ + -v "$(pwd)/.env:/app/.env:ro" \ + -v "$(pwd)/sync_mapping.json:/app/sync_mapping.json" \ + jotty-jira-sync:arm64 +``` + +Run a one-way sync instead: + +```bash +docker run --rm \ + -v "$(pwd)/sync_config.json:/app/sync_config.json:ro" \ + -v "$(pwd)/.env:/app/.env:ro" \ + -v "$(pwd)/sync_mapping.json:/app/sync_mapping.json" \ + jotty-jira-sync:arm64 --direction jira-to-jotty +``` + +Notes: + +- Keep `.env` and `sync_config.json` private because they contain credentials. +- `sync_mapping.json` is mounted so state persists across container runs. +- If you do not use `.env`, remove that `-v` mount and rely on `sync_config.json`. + ### CLI overrides Override config values from the command line: