optimised Dockerfile in a alpine image
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
This commit is contained in:
parent
2a679f97b6
commit
ea6287ad39
1 changed files with 19 additions and 14 deletions
33
Dockerfile
33
Dockerfile
|
@ -1,23 +1,28 @@
|
||||||
FROM rust:1.68-buster as builder
|
FROM rust:alpine AS builder
|
||||||
|
RUN apk add --no-cache openssl-dev musl-dev
|
||||||
RUN apt-get update && \
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
apt-get install -y libssl-dev pkg-config
|
|
||||||
|
|
||||||
WORKDIR /srv
|
WORKDIR /srv
|
||||||
|
|
||||||
# Build dependencies and cache them
|
# Build dependencies and cache them
|
||||||
COPY Cargo.* ./
|
COPY Cargo.* ./
|
||||||
RUN mkdir -p src && \
|
|
||||||
echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \
|
|
||||||
cargo build --release && \
|
|
||||||
rm -r src && \
|
|
||||||
rm target/release/deps/tricot*
|
|
||||||
|
|
||||||
# Build final app
|
# Build final app
|
||||||
COPY ./src ./src
|
COPY ./src ./src
|
||||||
RUN cargo build --release
|
RUN RUSTFLAGS=-Ctarget-feature=-crt-static \
|
||||||
|
cargo build \
|
||||||
|
--release \
|
||||||
|
--target=x86_64-unknown-linux-musl
|
||||||
|
|
||||||
FROM debian:bullseye-slim
|
RUN objcopy \
|
||||||
RUN apt-get update && apt-get install -y libssl1.1 iptables ca-certificates
|
--compress-debug-sections \
|
||||||
COPY --from=builder /srv/target/release/tricot /usr/local/sbin/tricot
|
target/x86_64-unknown-linux-musl/release/tricot \
|
||||||
CMD ["/usr/local/sbin/tricot"]
|
target/x86_64-unknown-linux-musl/release/tricot.compressed
|
||||||
|
|
||||||
|
FROM alpine
|
||||||
|
RUN apk add -U --no-cache ca-certificates libgcc
|
||||||
|
COPY --from=builder \
|
||||||
|
/srv/target/x86_64-unknown-linux-musl/release/tricot.compressed \
|
||||||
|
/usr/local/bin/tricot
|
||||||
|
|
||||||
|
CMD ["/usr/local/bin/tricot"]
|
||||||
|
|
Loading…
Reference in a new issue