-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
76 lines (57 loc) · 1.94 KB
/
Dockerfile
File metadata and controls
76 lines (57 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Build stage
FROM python:3.12-slim as builder
# Install system dependencies for building Python packages
RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
# Set working directory
WORKDIR /app
# Copy dependency files and README (needed by hatchling)
COPY pyproject.toml uv.lock .python-version README.md ./
# Copy source code (needed for build)
COPY src/ ./src/
COPY grin.py ./
# Install dependencies with uv
RUN uv sync --frozen --no-dev
# Production stage
FROM python:3.12-slim
# Install system dependencies required at runtime
RUN apt-get update && apt-get install -y \
gnupg \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r grin && useradd -r -g grin -d /app -s /bin/bash grin
# Set working directory
WORKDIR /app
# Install uv in production stage
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
# Copy pyproject.toml and uv.lock for uv run to work
COPY pyproject.toml uv.lock .python-version ./
# Copy application code
COPY . .
# Install production dependencies only
RUN uv sync --frozen --no-dev
# Create data directories with permissions
RUN mkdir -p /app/data /app/output /app/config /app/logs /app/staging /app/.gnupg /app/secrets /app/.config/grin-transfer && \
chown -R grin:grin /app
# Set environment variables
ENV PYTHONPATH="/app/src:${PYTHONPATH}"
ENV GRIN_CONFIG_DIR="/app/config"
ENV GRIN_DATA_DIR="/app/data"
ENV GRIN_OUTPUT_DIR="/app/output"
ENV GRIN_LOG_DIR="/app/logs"
ENV GRIN_STAGING_DIR="/app/staging"
# Switch to non-root user
USER grin
# Create volumes for persistent data
VOLUME ["/app/data", "/app/output", "/app/config", "/app/logs", "/app/staging"]
# Set default command using uv run to ensure virtual environment is used
ENTRYPOINT ["uv", "run", "python", "grin.py"]
CMD ["--help"]