Nova/Dockerfile
Matthieu Pignolet ea1d345147
Draft: New cross building for docker images (#37)
* Add .circleci/config.yml

* base

* base

* add architectures and cross build

* fix clippy warnings
2023-01-20 16:38:10 +04:00

28 lines
987 B
Docker

# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM tonistiigi/xx:master AS xx
FROM --platform=$BUILDPLATFORM rust:alpine as alpine_rbuild
RUN apk add clang lld protobuf-dev build-base git
# Copy the xx scripts
COPY --from=xx / /
# Copy source code
COPY . .
RUN --mount=type=cache,target=/root/.cargo/git/db \
--mount=type=cache,target=/root/.cargo/registry/cache \
--mount=type=cache,target=/root/.cargo/registry/index \
cargo fetch
ARG TARGETPLATFORM
RUN --mount=type=cache,target=/root/.cargo/git/db \
--mount=type=cache,target=/root/.cargo/registry/cache \
--mount=type=cache,target=/root/.cargo/registry/index \
xx-cargo build --release --target-dir ./build
#Copy from the build/<target triple>/release folder to the out folder
RUN mkdir ./out && cp ./build/*/release/* ./out || true
FROM alpine AS runtime
ARG COMPONENT
ENV COMPONENT=${COMPONENT}
COPY --from=alpine_rbuild /out/${COMPONENT} /usr/local/bin/
ENTRYPOINT /usr/local/bin/${COMPONENT}