Files

30 lines
787 B
Docker
Raw Permalink Normal View History

2024-04-21 23:02:59 +02:00
ARG ALPINE_VERSION=latest
2024-10-23 22:04:55 +02:00
FROM alpine:$ALPINE_VERSION AS builder
2024-04-21 23:02:59 +02:00
2024-10-23 23:04:24 +02:00
ARG RUST_VERSION=stable
2024-04-21 23:02:59 +02:00
COPY Cargo.lock /usr/src/
COPY Cargo.toml /usr/src/
WORKDIR /usr/src
RUN apk add --no-cache rustup build-base && \
2024-10-14 20:21:19 +02:00
rustup-init -qy --profile=minimal --default-toolchain=$RUST_VERSION && \
2024-04-21 23:02:59 +02:00
source "$HOME/.cargo/env" && \
2024-10-14 20:21:19 +02:00
mkdir src && echo "fn main() {}" > src/main.rs && \
cargo fetch && \
cargo build --release --target=x86_64-unknown-linux-musl && \
rm src/main.rs
COPY src/ /usr/src/src/
RUN source "$HOME/.cargo/env" && \
touch src/main.rs && \
2024-04-21 23:02:59 +02:00
cargo build --release --target=x86_64-unknown-linux-musl
FROM alpine:$ALPINE_VERSION
COPY --from=builder /usr/src/target/x86_64-unknown-linux-musl/release/web-template /usr/bin/
CMD [ "/usr/bin/web-template" ]