|
| 1 | +ARG UBI_MINIMAL_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal |
| 2 | +ARG UBI_BASE_IMAGE_TAG=latest |
| 3 | +ARG PROTOC_VERSION=29.3 |
| 4 | +ARG CONFIG_FILE=config/config.yaml |
| 5 | + |
| 6 | +## Rust builder ################################################################ |
| 7 | +# Specific debian version so that compatible glibc version is used |
| 8 | +FROM rust:1.87.0 AS rust-builder |
| 9 | +ARG PROTOC_VERSION |
| 10 | + |
| 11 | +ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse |
| 12 | + |
| 13 | +# Install protoc, no longer included in prost crate |
| 14 | +RUN cd /tmp && \ |
| 15 | + apt update && \ |
| 16 | + apt install -y cmake libclang-dev && \ |
| 17 | + curl -L -O https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-ppcle_64.zip; \ |
| 18 | + unzip protoc-*.zip -d /usr/local && \ |
| 19 | + rm protoc-*.zip |
| 20 | + |
| 21 | +ENV LIBCLANG_PATH=/usr/lib/llvm-14/lib/ |
| 22 | + |
| 23 | +WORKDIR /app |
| 24 | + |
| 25 | +COPY rust-toolchain.toml rust-toolchain.toml |
| 26 | + |
| 27 | +RUN rustup component add rustfmt |
| 28 | + |
| 29 | +## Orchestrator builder ######################################################### |
| 30 | +FROM rust-builder AS fms-guardrails-orchestr8-builder |
| 31 | +ARG CONFIG_FILE=config/config.yaml |
| 32 | + |
| 33 | +COPY build.rs *.toml LICENSE /app/ |
| 34 | +COPY ${CONFIG_FILE} /app/config/config.yaml |
| 35 | +COPY protos/ /app/protos/ |
| 36 | +COPY src/ /app/src/ |
| 37 | +COPY tests/ /app/tests/ |
| 38 | + |
| 39 | +WORKDIR /app |
| 40 | + |
| 41 | +# TODO: Make releases via cargo-release |
| 42 | +RUN cargo build --release |
| 43 | + |
| 44 | +# Copy test resources required for executing unit tests |
| 45 | +COPY tests/resources /app/tests/resources |
| 46 | +RUN cargo test |
| 47 | + |
| 48 | +## Release Image ################################################################ |
| 49 | + |
| 50 | +FROM ${UBI_MINIMAL_BASE_IMAGE}:${UBI_BASE_IMAGE_TAG} AS fms-guardrails-orchestr8-release |
| 51 | +ARG CONFIG_FILE=config/config.yaml |
| 52 | + |
| 53 | +COPY --from=fms-guardrails-orchestr8-builder /app/target/release/fms-guardrails-orchestr8 /app/bin/ |
| 54 | +COPY ${CONFIG_FILE} /app/config/config.yaml |
| 55 | + |
| 56 | +RUN microdnf install -y --disableplugin=subscription-manager shadow-utils compat-openssl11 && \ |
| 57 | + microdnf clean all --disableplugin=subscription-manager |
| 58 | + |
| 59 | +RUN groupadd --system orchestr8 --gid 1001 && \ |
| 60 | + adduser --system --uid 1001 --gid 0 --groups orchestr8 \ |
| 61 | + --create-home --home-dir /app --shell /sbin/nologin \ |
| 62 | + --comment "FMS Orchestrator User" orchestr8 |
| 63 | + |
| 64 | +USER orchestr8 |
| 65 | + |
| 66 | +HEALTHCHECK NONE |
| 67 | + |
| 68 | +ENV ORCHESTRATOR_CONFIG=/app/config/config.yaml |
| 69 | + |
| 70 | +CMD ["/app/bin/fms-guardrails-orchestr8"] |
0 commit comments