'Digitalocean App: failed to load /usr/app/start.sh

I really don't get this. I am trying to deploy my python app to from GitHub to docker using gunicorn to start the app. But I keep getting this error after the build is successful but before deployment can begin

starting non-root container [./start.sh]: creating process: failed to load /usr/app/start.sh: exec format error

I have tried changing the permission for the start.sh file but it doesnt change. This is my start.sh

gunicorn -b :5000 --access-logfile - --error-logfile - pixelshop:app

This is my docker

FROM python:latest
WORKDIR /usr/app
COPY . .
RUN apt-get update
RUN apt-get install -y libgl1-mesa-dev
RUN pip install -r requirements.txt
RUN pip install Flask
RUN pip install gunicorn
RUN chmod +x start.sh
ENTRYPOINT  ./start.sh


Solution 1:[1]

I think there are two things that could be happening here.

  1. As David Maze suggested, make sure to include the shebang as the first line in your entrypoint.sh file.

  2. My issue is that my new M1 Macbook Pro was using ARM64 architecture while DigitalOcean seems to only support AMD64 images. You can check your docker image with:

> docker inspect <YOUR_IMAGE_ID> --format '{{.Architecture}}'
arm64

If you see arm64 you then you should specify amd64 architecture in your Dockerfile as such:

FROM --platform=linux/amd64 python:latest
# Rest for Dockerfile...

Hope this helps someone in the future becuase I was beyond frustrated trying to figure out what changed when deploying a new image.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ben