Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
102 changes: 0 additions & 102 deletions .prek-config.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ install-backend: ## Install the backend dependencies
@echo "=> Backend dependencies installed"

.PHONY: install
install: clean destroy ## Install the project, dependencies, and pre-commit for local development
install: clean destroy ## Install the project, dependencies, and prek for local development
@if ! $(UV) --version > /dev/null; then $(MAKE) install-uv; fi
@$(MAKE) install-backend
@$(MAKE) install-frontend
Expand Down
69 changes: 69 additions & 0 deletions services/bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# syntax=docker/dockerfile:1

# ============================================================================
# Builder Stage: Install dependencies and build virtual environment
# ============================================================================
FROM python:3.12-slim AS builder

# Set working directory
WORKDIR /app

# Install system dependencies required for building Python packages
RUN apt-get update && apt-get install -y \
gcc \
g++ \
make \
&& rm -rf /var/lib/apt/lists/*

# Copy uv binary from official image
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Set uv environment variables for optimal performance
ENV UV_SYSTEM_PYTHON=1 \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy

# Copy workspace configuration files
COPY pyproject.toml uv.lock ./

# Copy shared packages and service code
COPY packages/byte-common ./packages/byte-common
COPY services/bot ./services/bot

# Install dependencies with frozen lockfile (no dev dependencies)
# This creates a .venv directory with all dependencies
RUN uv sync --frozen --no-dev --no-editable

# ============================================================================
# Runtime Stage: Minimal production image
# ============================================================================
FROM python:3.12-slim

# Set working directory
WORKDIR /app

# Create non-root user for security
RUN groupadd -r botuser && \
useradd -r -g botuser -u 1000 -d /app -s /sbin/nologin botuser

# Copy virtual environment from builder stage
COPY --from=builder --chown=botuser:botuser /app/.venv /app/.venv

# Copy application code from builder stage
COPY --from=builder --chown=botuser:botuser /app/services/bot /app/services/bot
COPY --from=builder --chown=botuser:botuser /app/packages/byte-common /app/packages/byte-common

# Copy workspace configuration (needed for uv run commands)
COPY --from=builder --chown=botuser:botuser /app/pyproject.toml /app/uv.lock ./

# Set PATH to use virtual environment binaries
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH="/app"

# Switch to non-root user
USER botuser

# Run the Discord bot
CMD ["python", "-m", "byte_bot"]
Loading