Unable to run simply rest service

Hello community,

It is my first experience with platform,
I am trying to run the simplest web service that returns hello world,

I’ve created a docker image for that

there are two platform, linux/amd64 and arm64,

I’ve successfully run both of them with my local docker on mac m2

full Dockerfile listing is

# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM node:latest as base
RUN npm install -g @moonrepo/cli
COPY . .
RUN moon tools:docker-prepare

# get only needed files prepared by moon
FROM  --platform=$BUILDPLATFORM rust:alpine as builder
RUN apk add clang lld musl-dev gcc
WORKDIR /output
COPY --from=base ./app/.moon/docker/workspace .
COPY --from=base ./app/.moon/docker/sources .
RUN cd apps/web_api \
    && cargo build --release --target-dir bin

FROM --platform=$BUILDPLATFORM alpine
COPY --from=builder /output/apps/web_api/bin/release/web_api /web_api
COPY --from=builder /output/data/assets /assets
COPY --from=builder /output/apps/web_api/Rocket.toml /Rocket.toml
## Configure rocket to listen on all interfaces.
## Expose the port that the application listens on.
EXPOSE 10000

# What the container should run when it is started.
CMD /web_api

in the logs I see this error

exec /bin/sh: exec format error

What is wrong with my image?

Does your service on Render have $BUILDPLATFORM defined?

That --platform=$BUILDPLATFORM parameter shouldn’t need to be specified, because you’re building for the local platform you’re running it on, not cross-compiling. If your Mac runs it, it gets arm64, if a Linux platform builds it, it gets linux/amd64. I suspect that is causing this issue, because the “exec format error” is ultimately saying that sh is an invalid (arm?) binary when it’s run on Render (Linux)

I have built image for two platforms, they are on docker hub already. I have succesfully run either amd64 or arm64 on docker desktop. I didn’t build the image on render.com

It works well on mac intel as well

Btw, is this CMD correct?

CMD [“/bin/sh” “-c” “/web_api”] ?

sorry, I just mixed up with BUILDPLATFORM and TARGETPLATFORM variables, replaced then rebuild everything again, works fine,

topic could be closed