tetcore-analytics 0.1.4

Tetcore Telemetry Analytics for Rust
FROM rust:slim as builder

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y libpq-dev

# build diesel first as there may be no changes and caching will be used
RUN echo "building diesel-cli" && \
  cargo install diesel_cli --root /tetcore-analytics --bin diesel --force --no-default-features --features postgres

WORKDIR /tetcore-analytics

# speed up docker build using pre-build dependencies
# http://whitfin.io/speeding-up-rust-docker-builds/
RUN USER=root cargo init --bin

# copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml

# this build step will cache your dependencies
RUN cargo build --release
RUN rm -rf ./src ./target/release/deps/tetcore_analytics-*

# copy your source tree
COPY ./src ./src

# ADD ./ ./

RUN echo "building tetcore-analytics" && \
  cargo build --release

FROM debian:stretch-slim
# metadata
LABEL maintainer="devops-team@parity.io" \
  vendor="Parity Technologies" \
  name="tetcoin/tetcore-analytics" \
  description="Tetcore Analytical and Visual Environment - Incoming telemetry" \
  url="https://github.com/tetcoin/tetcore-analytics/" \
  vcs-url="./"


RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y libpq5 && \
    DEBIAN_FRONTEND=noninteractive apt-get autoremove -y && \
    apt-get clean && \
    find /var/lib/apt/lists/ -type f -not -name lock -delete

RUN useradd -m -u 1000 -U -s /bin/sh -d /analytics analytics

COPY --from=builder /tetcore-analytics/target/release/tetcore-analytics /usr/local/bin/
COPY --from=builder /tetcore-analytics/bin/diesel /usr/local/bin/

COPY ./migrations /analytics/migrations
COPY ./static /srv/tetcore-analytics

WORKDIR /analytics
USER analytics
ENV RUST_BACKTRACE 1

ENTRYPOINT [ "/bin/sh", "-x", "-c", "/usr/local/bin/diesel migration run && exec /usr/local/bin/tetcore-analytics"]