Reputation: 143
I'm trying to build a compose file with Django services with an entrypoint for each service to perform migrations, but docker can't locate the entrypoint.sh when I mount my directory, but it works when I don't.
the container shows this error
exec /code/dev/entrypoint.sh: no such file or directory
dockerfile
FROM python:3.11-slim-bullseye
WORKDIR /code
COPY req.txt .
RUN pip3 install -r req.txt --no-cache-dir
COPY ./dev/entrypoint.sh ./dev/
RUN sed -i 's/\r$//g' ./dev/entrypoint.sh
RUN chmod +x ./dev/entrypoint.sh
# Convert line endings to Unix-style (LF)
RUN apt-get update && apt-get install -y dos2unix && dos2unix ./dev/entrypoint.sh && chmod +x ./dev/entrypoint.sh
COPY . .
ENTRYPOINT ["/code/dev/entrypoint.sh"]
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
compose.yaml
services:
auth:
build:
context: ./Auth
dockerfile: dev/dockerfile
container_name: Auth
env_file:
- "./Auth/Auth/.env"
ports:
- 8001:8000
expose:
- 8001
networks:
- backend
volumes:
- ./Auth:/code
artifact:
build:
context: ./Artifact
dockerfile: dev/dockerfile
container_name: Artifact
env_file:
- "./Artifact/Artifact/.env"
ports:
- 8002:8000
expose:
- 8002
networks:
- backend
volumes:
- ./Artifact:/code
networks:
backend:
entrypoint.sh
#!/bin/sh
# entrypoint.sh
python manage.py makemigrations
# Run migrations
python manage.py migrate
# Then run the main container command (passed to us as arguments)
exec "$@"
directory structure inside docker:
Upvotes: 1
Views: 1484