Files
web-template-rs/Dockerfile
dobiadi cf69376c5f
Some checks failed
build-and-pudh / docker (push) Failing after 28s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
Test action
2024-10-23 22:56:36 +02:00

29 lines
786 B
Docker

ARG ALPINE_VERSION=latest
FROM alpine:$ALPINE_VERSION AS builder
COPY Cargo.lock /usr/src/
COPY Cargo.toml /usr/src/
COPY src/ /usr/src/src/
WORKDIR /usr/src
RUN apk add --no-cache rustup build-base && \
rustup-init -qy --profile=minimal --default-toolchain=$RUST_VERSION && \
source "$HOME/.cargo/env" && \
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 && \
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" ]