|
| 1 | +# This Containerfile contains several stages: |
| 2 | +# |
| 3 | +# runtime-platform: Fedora base image with the required dependencies |
| 4 | +# added on top to run the SSE bridge. |
| 5 | +# |
| 6 | +# production: Production build with minimal dependencies |
| 7 | +# |
| 8 | +# debug: Debug build with additional tools |
| 9 | + |
| 10 | +ARG BASE_IMAGE=registry.fedoraproject.org/fedora:42 |
| 11 | + |
| 12 | +# |
| 13 | +# runtime-platform: Fedora base image with the required dependencies |
| 14 | +# |
| 15 | +FROM ${BASE_IMAGE} AS runtime-platform |
| 16 | + |
| 17 | +# Install required system packages |
| 18 | +RUN dnf -y update \ |
| 19 | + && dnf -y install --setopt=install_weak_deps=False python3 uv wget \ |
| 20 | + && dnf clean all \ |
| 21 | + && rm -rf /var/cache/dnf |
| 22 | + |
| 23 | +# Create non-root user |
| 24 | +RUN useradd -m -U bridge \ |
| 25 | + && mkdir -p /app \ |
| 26 | + && chown -R bridge:bridge /app |
| 27 | + |
| 28 | +USER bridge |
| 29 | +WORKDIR /app |
| 30 | + |
| 31 | +# |
| 32 | +# production: Production build with minimal dependencies |
| 33 | +# |
| 34 | +FROM runtime-platform AS production |
| 35 | + |
| 36 | +# Copy only dependency metadata first to maximize layer cache |
| 37 | +COPY --chown=bridge:bridge pyproject.toml README.md LICENSE uv.lock ./ |
| 38 | + |
| 39 | +# Resolve and install project dependencies into the system environment |
| 40 | +USER root |
| 41 | +RUN uv export --frozen --no-dev -o /tmp/requirements.txt \ |
| 42 | + && uv pip install --system --no-cache -r /tmp/requirements.txt \ |
| 43 | + && rm -f /tmp/requirements.txt |
| 44 | +USER bridge |
| 45 | + |
| 46 | +# Copy the rest of the project |
| 47 | +COPY --chown=bridge:bridge testing_farm_sse_bridge ./testing_farm_sse_bridge |
| 48 | + |
| 49 | +# Install the application itself without re-resolving dependencies |
| 50 | +USER root |
| 51 | +RUN uv pip install --system --no-cache --no-deps . |
| 52 | +USER bridge |
| 53 | + |
| 54 | +EXPOSE 10000 |
| 55 | + |
| 56 | +ENV HOST=0.0.0.0 \ |
| 57 | + PORT=10000 |
| 58 | + |
| 59 | +CMD ["testing-farm-sse-bridge"] |
| 60 | + |
| 61 | +# |
| 62 | +# debug: Debug build with additional tools |
| 63 | +# |
| 64 | +FROM runtime-platform AS debug |
| 65 | + |
| 66 | +# Install debug tools |
| 67 | +USER root |
| 68 | +RUN dnf -y install \ |
| 69 | + python3-pip \ |
| 70 | + python3-ipython \ |
| 71 | + python3-pytest \ |
| 72 | + && dnf clean all \ |
| 73 | + && rm -rf /var/cache/dnf |
| 74 | +USER bridge |
| 75 | + |
| 76 | +# Copy only dependency metadata first to maximize layer cache |
| 77 | +COPY --chown=bridge:bridge pyproject.toml README.md LICENSE uv.lock ./ |
| 78 | + |
| 79 | +# Resolve and install project dependencies including dev extras |
| 80 | +USER root |
| 81 | +RUN uv export --frozen --dev -o /tmp/requirements.txt \ |
| 82 | + && uv pip install --system --no-cache -r /tmp/requirements.txt \ |
| 83 | + && rm -f /tmp/requirements.txt |
| 84 | +USER bridge |
| 85 | + |
| 86 | +# Copy the rest of the project |
| 87 | +COPY --chown=bridge:bridge pyproject.toml README.md LICENSE ./ |
| 88 | +COPY --chown=bridge:bridge testing_farm_sse_bridge ./testing_farm_sse_bridge |
| 89 | + |
| 90 | +# Install the application itself without re-resolving dependencies |
| 91 | +USER root |
| 92 | +RUN uv pip install --system --no-cache --no-deps . |
| 93 | +USER bridge |
| 94 | + |
| 95 | +CMD ["testing-farm-sse-bridge", "--host=0.0.0.0", "--port=10000", "--log-level=debug"] |
0 commit comments