|
1 | | -# Build stage - install dependencies |
| 1 | +# Build stage |
2 | 2 | FROM python:3.14-slim AS builder |
3 | 3 |
|
4 | | -# Install uv for fast package management |
5 | | -COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv |
| 4 | +COPY --from=ghcr.io/astral-sh/uv:0.9 /uv /usr/local/bin/uv |
6 | 5 |
|
7 | 6 | WORKDIR /app |
8 | 7 |
|
9 | | -# Copy dependency files first for better layer caching |
10 | 8 | COPY pyproject.toml uv.lock ./ |
11 | | - |
12 | | -# Install dependencies into a virtual environment |
13 | 9 | RUN uv sync --frozen --no-dev --no-install-project |
14 | 10 |
|
15 | | -# Copy application code |
16 | 11 | COPY s3proxy/ ./s3proxy/ |
17 | | - |
18 | | -# Install the project itself |
19 | 12 | RUN uv sync --frozen --no-dev |
20 | 13 |
|
21 | 14 |
|
22 | | -# Runtime stage - minimal image |
| 15 | +# Runtime stage |
23 | 16 | FROM python:3.14-slim |
24 | 17 |
|
25 | | -# Install curl for healthchecks |
26 | | -RUN apt-get update && apt-get install -y --no-install-recommends curl \ |
27 | | - && rm -rf /var/lib/apt/lists/* |
28 | | - |
29 | | -# Create non-root user |
30 | 18 | RUN useradd --create-home --shell /bin/bash s3proxy |
31 | 19 |
|
32 | 20 | WORKDIR /app |
33 | 21 |
|
34 | | -# Copy virtual environment from builder |
35 | | -COPY --from=builder /app/.venv /app/.venv |
36 | | - |
37 | | -# Copy application code |
38 | | -COPY --from=builder /app/s3proxy /app/s3proxy |
39 | | - |
40 | | -# Set ownership |
41 | | -RUN chown -R s3proxy:s3proxy /app |
| 22 | +COPY --from=builder --chown=s3proxy:s3proxy /app/.venv /app/.venv |
| 23 | +COPY --from=builder --chown=s3proxy:s3proxy /app/s3proxy /app/s3proxy |
42 | 24 |
|
43 | 25 | USER s3proxy |
44 | 26 |
|
45 | | -# Add venv to path |
46 | | -ENV PATH="/app/.venv/bin:$PATH" |
47 | | -ENV PYTHONUNBUFFERED=1 |
48 | | -ENV PYTHONDONTWRITEBYTECODE=1 |
| 27 | +ENV PATH="/app/.venv/bin:$PATH" \ |
| 28 | + PYTHONUNBUFFERED=1 \ |
| 29 | + PYTHONDONTWRITEBYTECODE=1 |
49 | 30 |
|
50 | | -# Default environment variables |
51 | | -ENV S3PROXY_IP=0.0.0.0 |
52 | | -ENV S3PROXY_PORT=4433 |
53 | | -ENV S3PROXY_NO_TLS=true |
54 | | -ENV S3PROXY_REGION=us-east-1 |
55 | | -ENV S3PROXY_LOG_LEVEL=INFO |
| 31 | +ENV S3PROXY_IP=0.0.0.0 \ |
| 32 | + S3PROXY_PORT=4433 \ |
| 33 | + S3PROXY_NO_TLS=true \ |
| 34 | + S3PROXY_REGION=us-east-1 \ |
| 35 | + S3PROXY_LOG_LEVEL=INFO |
56 | 36 |
|
57 | 37 | EXPOSE 4433 |
58 | 38 |
|
59 | | -# Health check |
60 | | -HEALTHCHECK --interval=5s --timeout=10s --start-period=5s --retries=3 \ |
61 | | - CMD curl -f http://localhost:4433/healthz || exit 1 |
62 | | - |
63 | | -# Run the application with uvloop for better async performance |
64 | | -# Note: Multiple workers require external state store for multipart uploads |
65 | | -# Use --workers N if multipart state is moved to Redis/distributed store |
66 | 39 | CMD ["uvicorn", "s3proxy.main:app", "--host", "0.0.0.0", "--port", "4433", "--loop", "uvloop"] |
0 commit comments