Search code examples
pythondjangodockerdockerfilealpine-linux

Docker enrtypiont not found on django app with alpine python


This is my Dockerfile:

FROM python:alpine3.17

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# install psycopg2 dependencies
RUN apk update \
    && apk add postgresql-dev gcc python3-dev musl-dev

COPY Pipfile /app
COPY Pipfile.lock /app
RUN pip install pipenv
RUN pipenv install --system

COPY . /app


USER root
RUN chmod +x /app/entrypoint-prod.sh
ENTRYPOINT ["/app/entrypoint-prod.sh"]

This is my entrypoint-prod.sh

#!/bin/bash

# Apply migrations
python manage.py migrate --noinput

# Collect static
python manage.py collectstatic --no-input --clear

# Start the application
gunicorn grayti_backend.wsgi:application --bind 0.0.0.0:8000 --workers 3

When I run the image docker run -it myapp:latest, this is the output:

exec /app/entrypoint-prod.sh: no such file or directory

This error occured only when I moved from FROM python:3.10 to FROM python:alpine3.17

I tried the following but didn't work also:

USER root
RUN chmod +x entrypoint-prod.sh
ENTRYPOINT ["./entrypoint-prod.sh"]

Solution

  • The answer from Hans Kilian solved my problem. The problem was solved by replacing #!/bin/bash with #!/bin/sh in the entrypoint-prod.sh file.