Building a rust app in docker for x64, but from an m1 mac

I would like to build a actix web rust app on my m1 mac to target linux x64 machines. So far it appears my only issues is with openssl. I get the error

12.09 cargo:warning=cc1: error: unrecognized command-line option '-m64'
12.09
12.09 --- stderr
12.09 thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.103/build/main.rs:263:13:
12.09
12.09 Header expansion error:
12.09 Error { kind: ToolExecError, message: "Command "musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/usr/local/musl/include" "-I/usr/local/musl/include" "-E" "build/expando.c" with args musl-gcc did not execute successfully (status code exit status: 1)." }
12.09
12.09 Failed to find OpenSSL development headers.

My dockerfile is this
FROM rust:1.79 as builder
RUN apt-get update &&
apt-get install -y
musl-tools
musl-dev
libssl-dev
&& apt-get clean
RUN wget https://musl.cc/x86_64-linux-musl-cross.tgz &&
tar -xzf x86_64-linux-musl-cross.tgz &&
cp -r x86_64-linux-musl-cross/x86_64-linux-musl/ /usr/local/musl &&
rm -rf x86_64-linux-musl-cross.tgz x86_64-linux-musl-cross
RUN rustup target add x86_64-unknown-linux-musl

WORKDIR /usr/src/syntaxmakersserver
COPY ./server/. .
ENV OPENSSL_DIR=/usr/local/musl
OPENSSL_LIB_DIR=/usr/local/musl/lib
OPENSSL_INCLUDE_DIR=/usr/local/musl/include
PKG_CONFIG_ALLOW_CROSS=1
PKG_CONFIG_PATH=/usr/local/musl/lib/pkgconfig
CC=musl-gcc
CFLAGS="-I/usr/local/musl/include"
LDFLAGS="-L/usr/local/musl/lib"
RUN cargo build --target x86_64-unknown-linux-musl --release
RUN find / -name "syntaxmakers-server" 2>/dev/null

FROM debian:buster-slim
RUN apt-get update &&
apt-get install -y libssl1.1 &&
apt-get clean
COPY --from=builder /usr/src/syntaxmakersserver /usr/local/bin/syntaxmakersserver
WORKDIR /usr/local/bin/syntaxmakersserver
ENTRYPOINT ["./target/x86_64-unknown-linux-gnu/release/syntaxmakers-server"]

I have no idea really but I do wonder why you ar using such an old version of Debian. Buster is out of long term support, the latest is "bookworm". For which there are Docker images https://hub.docker.com/_/debian

Also perhaps you need to install libssl-dev which I believe has the openssl headers.