forked from hydro-project/hydroflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
28 lines (19 loc) · 1009 Bytes
/
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
# Compilation stage
FROM --platform=$BUILDPLATFORM rust:slim-buster AS build
ARG TARGETOS TARGETARCH
RUN apt-get update && apt-get install -y git pkg-config
RUN /bin/bash -c "if [ "${TARGETARCH}" == "arm64" ]; then apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu ; else apt-get install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu ; fi"
WORKDIR /usr/src/myapp
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
./scripts/build_dist_release.sh ${TARGETOS} ${TARGETARCH}
RUN mkdir -p xfer/examples
RUN ls -dR target/*/release/examples/* | grep -vE '^.*/[a-z_]+\-.*$' | grep -vE '^.*\.d$' | xargs -I{} cp {} xfer/examples/
RUN mkdir -p xfer/example_utils && cp hydroflow/example_utils/* xfer/example_utils/.
# Runtime stage
FROM rust:slim-buster
RUN apt-get update && apt-get install -y python3
WORKDIR /usr/src/myapp
COPY --from=build /usr/src/myapp/xfer/examples/* .
RUN mkdir -p example_utils
COPY --from=build /usr/src/myapp/xfer/example_utils/* ./example_utils/.