I have a Dockerized Svelte application that runs perfectly on my local machine, but I’m having trouble deploying it on AWS Lightsail. Here’s what I’ve done so far:
[3/Jul/2024:08:42:00] [deployment:1] Creating your deployment
[3/Jul/2024:08:42:13] exec /usr/local/bin/docker-entrypoint.sh: exec format error
[3/Jul/2024:08:43:02] [deployment:1] Started 1 new node
[3/Jul/2024:08:43:18] exec /usr/local/bin/docker-entrypoint.sh: exec format error
[3/Jul/2024:08:44:13] [deployment:1] Started 1 new node
[3/Jul/2024:08:44:22] exec /usr/local/bin/docker-entrypoint.sh: exec format error
[3/Jul/2024:08:45:27] [deployment:1] Started 1 new node
[3/Jul/2024:08:45:44] exec /usr/local/bin/docker-entrypoint.sh: exec format error
[3/Jul/2024:08:46:02] [deployment:1] Canceled
:3000
.FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json .
RUN npm ci
COPY . .
RUN npm run build
RUN npm prune --production
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY package.json .
EXPOSE 3000 # <--- I thought this would work
ENV NODE_ENV=production
CMD [ "node", "build" ]
When I run docker image on local machine, it will work without any issue.
I can access it from localhost:3000
or localhost
if i change port to :80
Docker Desktop uses tcp, so i thought that was a reason why i had this issue, but I am not able to add :3000
tcp as Public Endpoint.
I tested out with sveltekit app without any code modification (Skelton project). With Sveltkit dockerfile setup reference. So, i didn't have any env variable set on Lightsail.
I tried with Mext.js and had the same issue. Turns out that the error:
exec format error
typically occurs when there is an architecture mismatch between the Docker image and the host machine. This can happen if the Docker image is built for one architecture (e.g., x86_64
) and the host machine is running a different architecture (e.g., ARM64
).
My MacOS
was ARM64, while Lightsail was based on x86_64
.
✅ I tried building the same image with my Ubuntu x86_64
and everyting worked as I expected.
I am going to wait for best answer since using Linux for pushing images isn't too realistic. For now, I am going to use linux since I am still struggling to figure out how to create x86_64
image on ARM64
machine.