-
Notifications
You must be signed in to change notification settings - Fork 18
/
Dockerfile
68 lines (47 loc) · 2.33 KB
/
Dockerfile
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
65
66
67
68
ARG UBI_MINIMAL_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal
ARG UBI_BASE_IMAGE_TAG=latest
ARG PROTOC_VERSION=26.0
ARG CONFIG_FILE=config/config.yaml
## Rust builder ################################################################
# Specific debian version so that compatible glibc version is used
FROM rust:1.80.1-bullseye as rust-builder
ARG PROTOC_VERSION
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
# Install protoc, no longer included in prost crate
RUN cd /tmp && \
curl -L -O https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
unzip protoc-*.zip -d /usr/local && rm protoc-*.zip
WORKDIR /app
COPY rust-toolchain.toml rust-toolchain.toml
RUN rustup component add rustfmt
## Orchestrator builder #########################################################
FROM rust-builder as fms-guardrails-orchestr8-builder
COPY build.rs *.toml LICENSE /app/
COPY ${CONFIG_FILE} /app/config/config.yaml
COPY protos/ /app/protos/
COPY src/ /app/src/
WORKDIR /app
# TODO: Make releases via cargo-release
RUN cargo install --root /app/ --path .
## Tests stage ##################################################################
FROM fms-guardrails-orchestr8-builder as tests
RUN cargo test
## Lint stage ###################################################################
FROM fms-guardrails-orchestr8-builder as lint
RUN cargo clippy --all-targets --all-features -- -D warnings
## Formatting check stage #######################################################
FROM fms-guardrails-orchestr8-builder as format
RUN cargo fmt --check
## Release Image ################################################################
FROM ${UBI_MINIMAL_BASE_IMAGE}:${UBI_BASE_IMAGE_TAG} as fms-guardrails-orchestr8-release
COPY --from=fms-guardrails-orchestr8-builder /app/bin/ /app/bin/
COPY ${CONFIG_FILE} /app/config/config.yaml
RUN microdnf install -y --disableplugin=subscription-manager shadow-utils compat-openssl11 && \
microdnf clean all --disableplugin=subscription-manager
RUN groupadd --system orchestr8 --gid 1001 && \
adduser --system --uid 1001 --gid 0 --groups orchestr8 \
--create-home --home-dir /app --shell /sbin/nologin \
--comment "FMS Orchestrator User" orchestr8
USER orchestr8
ENV ORCHESTRATOR_CONFIG /app/config/config.yaml
CMD /app/bin/fms-guardrails-orchestr8