influxdb/Dockerfile.ci

79 lines
2.6 KiB
Docker

###
# Dockerfile for the image used in the Delorean CI tests
# As of October 202, it is rebuilt each night
#
# It expects to be run with the delorean repo checked out locally.
# for example:
#
# cd delorean
# docker build -f Dockerfile.ci .
##
# Build any binaries that can be copied into the CI image
# Note we build flatbuffers from source (pinned to a particualar version)
FROM rust:slim-buster AS flatc
RUN apt-get update \
&& mkdir -p /usr/share/man/man1 \
&& apt-get install -y \
git make clang cmake llvm \
--no-install-recommends \
&& git clone -b v1.12.0 -- 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
# Build actual image used for CI pipeline
FROM rust:slim-buster
COPY --from=flatc /usr/local/src/flatbuffers/flatc /usr/bin/flatc
# make Apt non-interactive
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90ci \
&& echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90ci
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& mkdir -p /usr/share/man/man1 \
&& apt-get install -y \
git locales sudo openssh-client ca-certificates tar gzip parallel \
unzip zip bzip2 gnupg curl make pkg-config libssl-dev \
musl musl-dev musl-tools clang llvm \
--no-install-recommends \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}
# Set timezone to UTC by default
RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
# Use unicode
RUN locale-gen C.UTF-8 || true
ENV LANG=C.UTF-8
RUN rustup toolchain install nightly-2020-04-22
RUN rustup component add rustfmt clippy --toolchain nightly-2020-04-22
RUN groupadd -g 1500 rust \
&& useradd -u 1500 -g rust -s /bin/bash -m rust \
&& echo 'rust ALL=NOPASSWD: ALL' >> /etc/sudoers.d/10-rust \
&& echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep
USER rust
ENV PATH /home/rust/.local/bin:/home/rust/bin:${PATH}
# Copy the source into the image
ADD . /home/rust/project
RUN sudo chown -R rust:rust /home/rust/project
RUN sudo chmod u+rwx /home/rust/project
RUN cd /home/rust/project && git checkout master && git reset --hard
# Compile the code and bake the results into the image, so actual CI
# builds are just incremental builds from the last time the image was
# made.
RUN cd /home/rust/project && cargo build --all && \
cargo clippy && \
cargo test --no-run
CMD ["/bin/bash"]