|
| 1 | +# ============================================================================= |
| 2 | +# Stage 1: Build isomdl-uniffi wheel (requires Rust) |
| 3 | +# ============================================================================= |
| 4 | +FROM python:3.12-slim-bookworm AS isomdl-build |
| 5 | + |
| 6 | +WORKDIR /build |
| 7 | + |
| 8 | +# Install build dependencies |
| 9 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 10 | + curl \ |
| 11 | + git \ |
| 12 | + build-essential \ |
| 13 | + && rm -rf /var/lib/apt/lists/* |
| 14 | + |
| 15 | +# Install Rust toolchain (minimal profile to save space) |
| 16 | +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal |
| 17 | +ENV PATH="/root/.cargo/bin:${PATH}" |
| 18 | + |
| 19 | +# Clone isomdl-uniffi with shallow clone |
| 20 | +ARG ISOMDL_BRANCH=fix/python-build-system |
| 21 | +RUN git clone --depth 1 --branch ${ISOMDL_BRANCH} \ |
| 22 | + https://github.com/Indicio-tech/isomdl-uniffi.git /build/isomdl-uniffi |
| 23 | + |
| 24 | +WORKDIR /build/isomdl-uniffi/python |
| 25 | + |
| 26 | +# Build wheel — limit Cargo parallelism to avoid Docker VM OOM on resource-constrained hosts |
| 27 | +# (CARGO_BUILD_JOBS=2 cuts peak memory roughly in half vs. the default all-cores build) |
| 28 | +RUN pip install --no-cache-dir build wheel setuptools |
| 29 | +ENV CARGO_BUILD_JOBS=2 |
| 30 | +RUN python setup.py bdist_wheel |
| 31 | + |
| 32 | +# ============================================================================= |
| 33 | +# Stage 2: Install ACA-Py and plugin dependencies |
| 34 | +# ============================================================================= |
1 | 35 | FROM python:3.12-slim-bookworm AS base |
| 36 | + |
2 | 37 | WORKDIR /usr/src/app |
3 | 38 |
|
4 | | -# Install and configure poetry |
5 | | -USER root |
| 39 | +# Install only required build/runtime dependencies (no Rust needed here) |
| 40 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 41 | + curl \ |
| 42 | + jq \ |
| 43 | + git \ |
| 44 | + && rm -rf /var/lib/apt/lists/* |
6 | 45 |
|
7 | | -# Install and configure poetry |
8 | | -WORKDIR /usr/src/app |
9 | | -ENV POETRY_VERSION=2.1.2 |
10 | | -ENV POETRY_HOME=/opt/poetry |
11 | | -RUN apt-get update && apt-get install -y curl jq && apt-get clean |
12 | | -RUN curl -sSL https://install.python-poetry.org | python - |
| 46 | +# Accept build argument for ACA-Py version |
| 47 | +ARG ACAPY_VERSION=1.4.0 |
13 | 48 |
|
14 | | -ENV PATH="/opt/poetry/bin:$PATH" |
15 | | -RUN poetry config virtualenvs.in-project true |
| 49 | +# Clone ACA-Py source with shallow clone |
| 50 | +RUN git clone --depth 1 --branch ${ACAPY_VERSION} \ |
| 51 | + https://github.com/openwallet-foundation/acapy.git /usr/src/acapy |
16 | 52 |
|
17 | | -# Setup project |
18 | | -RUN mkdir oid4vc && touch oid4vc/__init__.py |
19 | | -RUN mkdir jwt_vc_json && touch jwt_vc_json/__init__.py |
20 | | -RUN mkdir sd_jwt_vc && touch sd_jwt_vc/__init__.py |
21 | | -RUN mkdir mso_mdoc && touch mso_mdoc/__init__.py |
22 | | -COPY oid4vc/pyproject.toml oid4vc/poetry.lock oid4vc/README.md ./ |
23 | | -RUN poetry install --without dev --all-extras |
24 | | -USER $user |
| 53 | +WORKDIR /usr/src/acapy |
25 | 54 |
|
26 | | -FROM python:3.12-bookworm |
| 55 | +# Install ACA-Py |
| 56 | +RUN pip install --no-cache-dir -e . |
| 57 | +RUN pip install --no-cache-dir configargparse |
27 | 58 |
|
| 59 | +# Setup plugin project structure |
28 | 60 | WORKDIR /usr/src/app |
29 | | -COPY --from=base /usr/src/app/.venv /usr/src/app/.venv |
30 | | -ENV PATH="/usr/src/app/.venv/bin:$PATH" |
31 | | -RUN apt-get update && apt-get install -y curl jq && apt-get clean |
| 61 | + |
| 62 | +# Copy the entire plugin source tree |
| 63 | +COPY oid4vc/pyproject.toml ./ |
| 64 | +COPY oid4vc/README.md ./ |
| 65 | +COPY oid4vc/oid4vc/ oid4vc/ |
32 | 66 | COPY oid4vc/jwt_vc_json/ jwt_vc_json/ |
33 | 67 | COPY oid4vc/mso_mdoc/ mso_mdoc/ |
34 | 68 | COPY oid4vc/sd_jwt_vc/ sd_jwt_vc/ |
35 | | -COPY oid4vc/oid4vc/ oid4vc/ |
36 | 69 | COPY status_list/ status_list/ |
37 | 70 | RUN pip install -e ./status_list |
| 71 | + |
| 72 | +# Install isomdl-uniffi from builder stage |
| 73 | +COPY --from=isomdl-build /build/isomdl-uniffi/python/dist/*.whl /tmp/ |
| 74 | +RUN pip install --no-cache-dir /tmp/*.whl && rm -rf /tmp/*.whl |
| 75 | + |
| 76 | +# Install the plugin with extras for mso_mdoc and sd_jwt_vc |
| 77 | +RUN pip install --no-cache-dir -e ".[mso_mdoc,sd_jwt_vc]" |
| 78 | + |
| 79 | +# ============================================================================= |
| 80 | +# Stage 3: Final slim runtime image |
| 81 | +# ============================================================================= |
| 82 | +FROM python:3.12-slim-bookworm |
| 83 | + |
| 84 | +WORKDIR /usr/src/app |
| 85 | + |
| 86 | +# Copy the complete environment from base stage |
| 87 | +COPY --from=base /usr/src/acapy /usr/src/acapy |
| 88 | +COPY --from=base /usr/src/app /usr/src/app |
| 89 | + |
| 90 | +# Install only runtime dependencies |
| 91 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 92 | + curl \ |
| 93 | + jq \ |
| 94 | + && apt-get clean \ |
| 95 | + && rm -rf /var/lib/apt/lists/* |
| 96 | + |
| 97 | +# Copy the entire Python environment from base stage, including site-packages |
| 98 | +COPY --from=base /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages |
| 99 | +COPY --from=base /usr/local/bin /usr/local/bin |
| 100 | + |
| 101 | +# Copy dev config |
38 | 102 | RUN mkdir -p /usr/src/app/docker |
39 | 103 | COPY oid4vc/docker/dev.yml /usr/src/app/docker/dev.yml |
40 | 104 | COPY oid4vc/docker/dev-verifier.yml /usr/src/app/docker/dev-verifier.yml |
41 | | -COPY oid4vc/docker/default.yml /usr/src/app/default.yml |
| 105 | +COPY oid4vc/docker/default.yml /usr/src/app/docker/default.yml |
| 106 | + |
| 107 | +# Expose ports |
| 108 | +EXPOSE 8030 8031 8032 |
| 109 | + |
| 110 | +# Add health check |
| 111 | +HEALTHCHECK --interval=10s --timeout=5s --retries=12 --start-period=60s \ |
| 112 | + CMD curl -f http://localhost:${ACAPY_ADMIN_PORT:-8021}/status/ready || exit 1 |
42 | 113 |
|
43 | | -ENTRYPOINT ["/bin/bash", "-c", "aca-py \"$@\"", "--"] |
44 | | -CMD ["start", "--arg-file", "default.yml"] |
| 114 | +# Set working directory and run ACA-Py |
| 115 | +WORKDIR /usr/src/acapy |
| 116 | +CMD ["python", "-m", "acapy_agent", "start", "--arg-file", "/usr/src/app/docker/dev.yml"] |
0 commit comments