Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch to scratch base image #1955

Merged
merged 3 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rust/target
50 changes: 33 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
ARG BASE_IMAGE=gcr.io/distroless/cc-debian12
ARG BASE_IMAGE=scratch
ARG ARCH=$TARGETARCH
####################################################################################################
# base
####################################################################################################
FROM debian:bullseye as base
FROM alpine:3.17 AS base
ARG ARCH
RUN apk update && apk upgrade && \
apk add ca-certificates && \
apk --no-cache add tzdata
ARG ARCH

COPY dist/numaflow-linux-${ARCH} /bin/numaflow
Expand All @@ -13,12 +17,10 @@ RUN chmod +x /bin/numaflow
####################################################################################################
# extension base
####################################################################################################
FROM rust:1.79-bookworm as extension-base

RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
FROM rust:1.80-bookworm AS extension-base
ARG TARGETPLATFORM

RUN apt-get update
RUN apt-get install protobuf-compiler -y
RUN apt-get update && apt-get install protobuf-compiler -y

RUN cargo new numaflow
# Create a new empty shell project
Expand All @@ -43,8 +45,15 @@ COPY ./rust/serving/Cargo.toml ./serving/Cargo.toml
COPY ./rust/Cargo.toml ./rust/Cargo.lock ./

# Build to cache dependencies
RUN mkdir -p src/bin && echo "fn main() {}" > src/bin/main.rs && \
cargo build --workspace --all --release
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
case ${TARGETPLATFORM} in \
"linux/amd64") TARGET="x86_64-unknown-linux-gnu" ;; \
"linux/arm64") TARGET="aarch64-unknown-linux-gnu" ;; \
*) echo "Unsupported platform: ${TARGETPLATFORM}" && exit 1 ;; \
esac && \
mkdir -p src/bin && echo "fn main() {}" > src/bin/main.rs && \
RUSTFLAGS='-C target-feature=+crt-static' cargo build --workspace --all --release --target ${TARGET}

# Copy the actual source code files of the main project and the subprojects
COPY ./rust/src ./src
Expand All @@ -57,30 +66,37 @@ COPY ./rust/monovertex/build.rs ./monovertex/build.rs
COPY ./rust/monovertex/proto ./monovertex/proto

# Build the real binaries
RUN touch src/bin/main.rs && \
cargo build --workspace --all --release
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
case ${TARGETPLATFORM} in \
"linux/amd64") TARGET="x86_64-unknown-linux-gnu" ;; \
"linux/arm64") TARGET="aarch64-unknown-linux-gnu" ;; \
*) echo "Unsupported platform: ${TARGETPLATFORM}" && exit 1 ;; \
esac && \
touch src/bin/main.rs && \
RUSTFLAGS='-C target-feature=+crt-static' cargo build --workspace --all --release --target ${TARGET} && \
cp -pv target/${TARGET}/release/numaflow /root/numaflow

####################################################################################################
# numaflow
####################################################################################################
ARG BASE_IMAGE
FROM debian:bookworm as numaflow

# Install necessary libraries
RUN apt-get update && apt-get install -y libssl3
FROM ${BASE_IMAGE} AS numaflow

COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=base /bin/numaflow /bin/numaflow
COPY ui/build /ui/build

COPY --from=extension-base /numaflow/target/release/numaflow /bin/numaflow-rs
COPY --from=extension-base /root/numaflow /bin/numaflow-rs
COPY ./rust/serving/config config

ENTRYPOINT [ "/bin/numaflow" ]

####################################################################################################
# testbase
####################################################################################################
FROM alpine:3.17 as testbase
FROM alpine:3.17 AS testbase
RUN apk update && apk upgrade && \
apk add ca-certificates && \
apk --no-cache add tzdata
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DIST_DIR=${CURRENT_DIR}/dist
BINARY_NAME:=numaflow
DOCKERFILE:=Dockerfile
DEV_BASE_IMAGE:=debian:bookworm
RELEASE_BASE_IMAGE:=debian:bookworm
RELEASE_BASE_IMAGE:=scratch

BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse HEAD)
Expand Down
Loading
Loading