diff --git a/services/feature-flags/Dockerfile b/services/feature-flags/Dockerfile index 84bcbd889..5fc66ffe7 100644 --- a/services/feature-flags/Dockerfile +++ b/services/feature-flags/Dockerfile @@ -1,44 +1,35 @@ -FROM commapp/services-base:1.3.2 as builder +FROM rust:1.70-bullseye as builder -ENV PATH=/root/.cargo/bin:$PATH - -# Install Curl -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y curl \ +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential cmake git libgtest-dev libssl-dev zlib1g-dev \ && rm -rf /var/lib/apt/lists/* -# Install Rust -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y - -RUN mkdir -p /home/comm/app/feature-flags -WORKDIR /home/comm/app/feature-flags -RUN cargo init --bin +WORKDIR /home/root/app/feature-flags -# Cache build dependencies in a new layer -COPY services/blob/Cargo.toml services/blob/Cargo.lock ./ -COPY services/comm-services-lib ../comm-services-lib -RUN cargo build --release +ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse # Copy actual application sources -COPY services/feature-flags . +COPY services/comm-services-lib ../comm-services-lib +COPY services/feature-flags ./ -# Remove the previously-built binary so that only the application itself is -# rebuilt -RUN rm -f ./target/release/deps/feature-flags* -RUN cargo build --release +RUN cargo install --locked --path . # Runner stage -FROM commapp/services-base:1.3.2 as runner +FROM debian:bullseye-slim as runner -# Create a new user comm and use it to run subsequent commands -RUN useradd -m comm -USER comm +# Update dependencies, install ca-certificates which are required for TLS +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* # Only copy built binary from builder stage +COPY --from=builder /usr/local/cargo/bin/feature-flags /usr/local/bin/feature-flags WORKDIR /home/comm/app/feature-flags -COPY --from=builder /home/comm/app/feature-flags/target/release/feature-flags . -ARG COMM_SERVICES_SANDBOX -ENV COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX} +# Create a new user comm and use it to run subsequent commands +RUN useradd -m comm +USER comm + +ENV RUST_LOG=info -CMD ./feature-flags +CMD ["feature-flags"]