build: use docker for building instead of the host

This commit is contained in:
Job 2023-07-21 16:46:55 +02:00
parent b1094768aa
commit f893f1967a
Signed by: Job79
SSH Key Fingerprint: SHA256:BezbKv3jZaqu7SdNrZM0e42b8nlNwh63zaVj/pUxc7U

@ -1,8 +1,21 @@
FROM rust:alpine3.18 AS builder
WORKDIR /build
RUN apk add --no-cache musl-dev
COPY . ./
RUN apk --print-arch
RUN case "$(apk --print-arch)" in \
x86_64) cargo build --target x86_64-unknown-linux-musl --release; \
mv ./target/x86_64-unknown-linux-musl /release ;; \
aarch64) cargo build --target aarch64-unknown-linux-musl --release; \
mv ./target/aarch64-unknown-linux-musl /release ;; \
esac
FROM alpine:edge FROM alpine:edge
WORKDIR /app WORKDIR /app
COPY ./target/x86_64-unknown-linux-musl/release/ /app COPY --from=builder /release/* /app
COPY ./about.html /app/about.html COPY ./about.html /app/about.html
EXPOSE 8080 EXPOSE 8080
CMD [ "./pastabble" ] CMD [ "./pastabble" ]