-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (48 loc) · 2.28 KB
/
Dockerfile
File metadata and controls
64 lines (48 loc) · 2.28 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
# syntax=docker/dockerfile:1.7
# =============================================================================
# Stage 1: Builder - install app into a uv-managed venv
# =============================================================================
FROM python:3.12-slim AS builder
# Install uv from the official distroless image (pinned version)
COPY --from=ghcr.io/astral-sh/uv:0.11.7 /uv /uvx /bin/
# Container build defaults recommended for uv in Docker
ENV UV_NO_DEV=1 \
UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_PYTHON_DOWNLOADS=0
WORKDIR /app
# Install dependencies first for better layer caching
COPY pyproject.toml uv.lock README.md LICENSE ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-install-project --no-editable
# Copy source and install project non-editable into the venv
COPY src/ ./src/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-editable
# =============================================================================
# Stage 2: Runtime - minimal image with only project environment
# =============================================================================
FROM python:3.12-slim AS runtime
# Labels for container registry
LABEL org.opencontainers.image.title="x2raindrop-cli"
LABEL org.opencontainers.image.description="CLI tool to sync X (Twitter) Bookmarks to Raindrop.io"
LABEL org.opencontainers.image.source="https://github.com/dotWee/py-x2raindrop-cli"
LABEL org.opencontainers.image.licenses="WTFPL"
# Create non-root user for security
RUN groupadd --gid 1000 x2raindrop \
&& useradd --uid 1000 --gid 1000 --shell /bin/bash --create-home x2raindrop
# Copy only the virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Create data directory and set ownership
RUN mkdir -p /data && chown x2raindrop:x2raindrop /data
# Use the venv executables directly
ENV PATH="/app/.venv/bin:$PATH"
# Switch to non-root user
USER x2raindrop
# Set working directory where config and state will be stored
WORKDIR /data
# The CLI reads config.toml and .x2raindrop/ from the current working directory.
# Mount your local directory to /data to persist configuration and state:
# docker run -v "$PWD":/data ghcr.io/dotwee/x2raindrop-cli sync --collection 12345
ENTRYPOINT ["x2raindrop"]
CMD ["--help"]