diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2eb0360 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,48 @@ +# Poetry (except pyproject.toml and poetry.lock) +.poetry +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# Virtual environments +venv/ +env/ +ENV/ +.venv + +# IDE +.idea/ +.vscode/ +*.swp +*.swo + +# Testing +.pytest/ +.coverage +htmlcov/ +.tox/ +.mypy_cache/ + +# Documentation (except README.md) +*.md +!README.md # Keep README for documentation + +# Build artifacts +dist/ +build/ +*.whl + +# Slack export (if accidentally included) +*.zip +!docker-compose.yml # docker-compose stays + +# Misc +.git/ +.gitignore +.gitattributes +*.log +.env +.env.local +.DS_Store +Thumbs.db diff --git a/.gitignore b/.gitignore index e35f24b..00b09f7 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,6 @@ target/ .vscode # Environments -venv/ \ No newline at end of file +venv/ + +slack-export.zip diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c85cd84 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +# syntax=docker/dockerfile:1.4 + +# Build stage +FROM python:3.12-slim as builder + +WORKDIR /app + +# Install dependencies via pip (simpler for Docker) +COPY pyproject.toml poetry.lock ./ +RUN pip install --no-cache-dir click werkzeug flask markdown2 emoji frozen-flask + +# Runtime stage +FROM python:3.12-slim as runtime + +# Install curl for healthcheck (optional) +RUN apt-get update && apt-get install -y \ + curl \ + && rm -rf /var/lib/apt/lists/* \ + && apt-get purge -y --auto-remove + +WORKDIR /app + +# Copy dependencies from builder to ensure they're available in the runtime image +COPY --from=builder /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/ +COPY --from=builder /usr/local/bin/ /usr/local/bin/ + +# Copy application code +COPY . . + +# Create user with UID/GID matching host for file permissions +RUN groupadd -g 1000 app && useradd -u 1000 -g app -m app + +# Switch to non-root user +USER app + +# Expose default port +EXPOSE 5000 + +# Health check (optional) +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:5000/ || exit 1 + +# Default command - can be overridden +CMD ["python", "app.py", "--help"] diff --git a/README.md b/README.md index 08603f4..9bb8b2e 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,64 @@ Options: ``` +## Docker + +You can run `slack-export-viewer` in a container using Docker and Docker Compose. + +### Prerequisites + +- Docker and Docker Compose installed +- Your Slack export archive (`.zip` file or directory) + +### Quick Start + +1. Build and run the container: + +```bash +docker-compose up --build +``` + +2. Open your browser to [http://localhost:5000](http://localhost:5000) + +### Configuration + +Before running, customize the `docker-compose.yml` file: + +- **Archive path**: Update the `source` in the volumes section to point to your Slack export archive + ```yaml + volumes: + - type: bind + source: ./your-export.zip # Change this path + target: /app/slack-export.zip + read_only: true + ``` + +- **Environment variables**: Modify the `environment` section to set options: + ```yaml + environment: + - SEV_ARCHIVE=/app/slack-export.zip + - SEV_PORT=5000 + - SEV_IP=0.0.0.0 + - SEV_NO_BROWSER=true + - SEV_CHANNELS=general,random + - SEV_SHOW_DMS=false + ``` + +See the [Usage](#usage) section for all available command-line options. + +### Running in Background + +```bash +docker-compose up -d +``` + +### Stopping the Container + +```bash +docker-compose down +``` + + ## Usage ### 1) Grab your Slack team's export diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..61c0f7f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +services: + slack-export-viewer: + build: + dockerfile: Dockerfile + target: runtime + image: slack-export-viewer:latest + container_name: slack-export-viewer + ports: + - "5000:5000" + volumes: + # Mount your Slack export archive directory/zip + - type: bind + source: ./slack-export.zip # CHANGE THIS to your archive path + target: /app/slack-export.zip + read_only: true + # Optional: persist cache or output directory + - slack-data:/app/.cache/slackviewer + environment: + - SEV_ARCHIVE=/app/slack-export.zip + - SEV_PORT=5000 + - SEV_IP=0.0.0.0 + - SEV_NO_BROWSER=true + # Optional configuration: + # - SEV_CHANNELS=general,random + # - SEV_HTML_ONLY=false + # - SEV_DEBUG=true + # - SEV_SHOW_DMS=false + # - SEV_NO_SIDEBAR=false + command: > + python app.py + --archive /app/slack-export.zip + --port 5000 + --ip 0.0.0.0 + --no-browser + +volumes: + slack-data: