Commit df5db521 authored by Aljaž Srebrnič's avatar Aljaž Srebrnič

Enhance docker build

parent 7fbb0887
FROM rust:1.36.0
FROM rust:1.36.0 as cargo-build
RUN apt-get update && \
apt-get install musl-tools -y && \
rm -rf /var/lib/apt/lists/*
RUN rustup target add x86_64-unknown-linux-musl
WORKDIR /usr/src/mittelab-status
COPY . .
COPY Cargo.toml Cargo.toml
RUN mkdir src/ && \
echo "fn main() {println!(\"if you see this, the build broke\")}" > src/
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl
COPY src/ src/
RUN rm -f target/x86_64-unknown-linux-musl/release/deps/mittelab-status* \
&& RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl
# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
FROM alpine:latest
RUN addgroup -g 1000 mittelab-status
RUN adduser -D -s /bin/sh -u 1000 -G mittelab-status mittelab-status
WORKDIR /home/mittelab-status/bin/
COPY --from=cargo-build /usr/src/mittelab-status/target/x86_64-unknown-linux-musl/release/mittelab-status .
RUN chown mittelab-status:mittelab-status mittelab-status
USER mittelab-status
RUN cargo install --path .
CMD ["mittelab-status"]
CMD ["./mittelab-status"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment