build using official image

This commit is contained in:
Robin Appelman 2021-11-10 13:03:55 +01:00
commit f6602539c3

View file

@ -1,21 +1,22 @@
FROM ekidd/rust-musl-builder AS build FROM rust:alpine AS build
COPY Cargo.toml Cargo.lock ./ COPY Cargo.toml Cargo.lock ./
# Build with a dummy main to pre-build dependencies # Build with a dummy main to pre-build dependencies
RUN mkdir src && \ RUN apk add --no-cache alpine-sdk && \
mkdir src && \
echo "fn main(){}" > src/main.rs && \ echo "fn main(){}" > src/main.rs && \
cargo build --release && \ cargo build --release --target x86_64-unknown-linux-musl && \
rm -r src rm -r src
COPY src/* ./src/ COPY src/* ./src/
RUN sudo chown -R rust:rust . && touch src/main.rs
RUN cargo build --release RUN touch src/main.rs && \
cargo build --release --target x86_64-unknown-linux-musl
FROM scratch FROM scratch
COPY --from=build /home/rust/src/target/x86_64-unknown-linux-musl/release/taspromto / COPY --from=build /target/x86_64-unknown-linux-musl/release/taspromto /
EXPOSE 80 EXPOSE 80
CMD ["/taspromto"] CMD ["/taspromto"]