feat: Simplify Dockerfile

Simplify Dockerfile by re-using toolchain and build dependencies from the image used to run iox's CI
system.
pull/24376/head
Marko Mikulicic 2021-03-02 17:43:38 +01:00 committed by kodiakhq[bot]
parent 51981c92f5
commit 4643dee61a
1 changed files with 6 additions and 19 deletions

View File

@ -1,34 +1,21 @@
#syntax=docker/dockerfile:1.2
FROM rust:slim-buster AS build
FROM quay.io/influxdb/rust:ci as build
# Build flatbuffers, a dependency of influxdb_iox
ARG flatbuffers_version="v1.12.0"
RUN apt-get update \
&& apt-get install -y \
git make clang cmake llvm libssl-dev pkg-config \
--no-install-recommends \
&& git clone -b ${flatbuffers_version} -- https://github.com/google/flatbuffers.git /usr/local/src/flatbuffers \
&& cmake -S /usr/local/src/flatbuffers -B /usr/local/src/flatbuffers \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
&& make -C /usr/local/src/flatbuffers -j $(nproc) flatc \
&& ln /usr/local/src/flatbuffers/flatc /usr/bin/flatc
# cache mounts below may already exist and owned by root
USER root
# Build influxdb_iox
COPY . /influxdb_iox
WORKDIR /influxdb_iox
RUN \
--mount=type=cache,id=influxdb_iox_rustup,sharing=locked,target=/usr/local/rustup \
rustup component add rustfmt
RUN \
--mount=type=cache,id=influxdb_iox_rustup,sharing=locked,target=/usr/local/rustup \
--mount=type=cache,id=influxdb_iox_registry,sharing=locked,target=/usr/local/cargo/registry \
--mount=type=cache,id=influxdb_iox_git,sharing=locked,target=/usr/local/cargo/git \
--mount=type=cache,id=influxdb_iox_target,sharing=locked,target=/influxdb_iox/target \
du -cshx /usr/local/rustup /usr/local/cargo/registry /usr/local/cargo/git /influxdb_iox/target && \
du -cshx /usr/local/cargo/registry /usr/local/cargo/git /influxdb_iox/target && \
cargo build --target-dir /influxdb_iox/target --release && \
cp /influxdb_iox/target/release/influxdb_iox /root/influxdb_iox && \
du -cshx /usr/local/rustup /usr/local/cargo/registry /usr/local/cargo/git /influxdb_iox/target
du -cshx /usr/local/cargo/registry /usr/local/cargo/git /influxdb_iox/target
FROM debian:buster-slim