diff --git a/Dockerfile b/Dockerfile index f9a6e4e..c373e08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,6 @@ FROM rust:1.80 AS builder ARG TARGETPLATFORM USER 1000 -WORKDIR /usr/src/ - RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ rustup target add x86_64-unknown-linux-musl; \ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ @@ -12,11 +10,10 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ else exit 1; \ fi -WORKDIR /usr/src/whatismyip +WORKDIR /app/whatismyip COPY . ./ -RUN --mount=type=cache,target=/usr/src/whatismyip/target \ - if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ cargo build --target=x86_64-unknown-linux-musl --release ; \ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ cargo build --target=armv7-unknown-linux-musleabihf --release ; \ @@ -25,19 +22,9 @@ RUN --mount=type=cache,target=/usr/src/whatismyip/target \ else exit 1; \ fi -RUN --mount=type=cache,target=/usr/src/whatismyip/target \ - if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ - cargo install --target=x86_64-unknown-linux-musl --path . ; \ - elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ - cargo install --target=armv7-unknown-linux-musleabihf --path . ; \ - elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ - cargo install --target=aarch64-unknown-linux-musl --path . ; \ - else exit 1; \ - fi - # Bundle Stage FROM scratch -COPY --from=builder /usr/local/cargo/bin/whatismyip . +COPY --from=builder /app/whatismyip/target/*/release/whatismyip . RUN ["./whatismyip", "-l"] USER 1000 ENTRYPOINT ["./whatismyip"]