optimize dockerfile to cache build-tools
Signed-off-by: Tianyue Ren <rentianyue-jk@360shuke.com>
This commit is contained in:
parent
b1f81d08f6
commit
730c1d32ef
|
@ -1,8 +1,5 @@
|
||||||
FROM alpine:3.18.2 AS builder
|
FROM alpine:3.18.2 AS builder
|
||||||
|
|
||||||
COPY Cargo.* /tmp/iptoasn/
|
|
||||||
COPY src /tmp/iptoasn/src
|
|
||||||
|
|
||||||
WORKDIR /tmp/iptoasn
|
WORKDIR /tmp/iptoasn
|
||||||
|
|
||||||
RUN apk add --update --no-cache ca-certificates \
|
RUN apk add --update --no-cache ca-certificates \
|
||||||
|
@ -12,18 +9,23 @@ RUN apk add --update --no-cache ca-certificates \
|
||||||
&& apk add --no-cache --virtual .build-rust \
|
&& apk add --no-cache --virtual .build-rust \
|
||||||
rust \
|
rust \
|
||||||
cargo \
|
cargo \
|
||||||
libressl-dev \
|
libressl-dev
|
||||||
\
|
|
||||||
&& cargo build --release \
|
|
||||||
&& strip target/release/iptoasn-webservice \
|
|
||||||
&& mv target/release/iptoasn-webservice /usr/bin/iptoasn-webservice \
|
|
||||||
&& adduser -D app \
|
|
||||||
\
|
|
||||||
&& apk del .build-rust \
|
|
||||||
&& rm -rf ~/.cargo \
|
|
||||||
/var/cache/apk/* \
|
|
||||||
/tmp/*
|
|
||||||
|
|
||||||
|
COPY Cargo.* /tmp/iptoasn/
|
||||||
|
COPY src /tmp/iptoasn/src
|
||||||
|
|
||||||
|
RUN cargo build --release \
|
||||||
|
&& strip target/release/iptoasn-webservice
|
||||||
|
|
||||||
|
FROM alpine:3.18.2 as prod
|
||||||
|
|
||||||
|
RUN apk add --update --no-cache ca-certificates \
|
||||||
|
libressl \
|
||||||
|
llvm-libunwind \
|
||||||
|
libgcc \
|
||||||
|
&& adduser -D app
|
||||||
|
|
||||||
|
COPY --from=0 /tmp/iptoasn/target/release/iptoasn-webservice /usr/bin/iptoasn-webservice
|
||||||
COPY docker/iptoasn-entrypoint.sh /iptoasn-entrypoint.sh
|
COPY docker/iptoasn-entrypoint.sh /iptoasn-entrypoint.sh
|
||||||
RUN chmod +x /iptoasn-entrypoint.sh
|
RUN chmod +x /iptoasn-entrypoint.sh
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue