I have a docker container that relies on a database being created and populated before it can run successfully. I have tried to accomodate for this by running a wait-for-it script before the main entrypoint of the container, problem is, the script never seems to run. I wont copy the entirety of the error because it is massive, but the gist is that there is an echo statement in my script that I cannot spot in the output.
My Dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS dev
WORKDIR /app
RUN mkdir -p startup
COPY ./waitForIt.sh /startup/
COPY ./appEntryPoint.sh /startup/
RUN chmod +x /startup/appEntryPoint.sh
COPY App.WebUI/App.WebUI.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish App.sln -c Release -o out
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
EXPOSE 80
COPY --from=dev /app/out .
ENTRYPOINT ["/startup/appEntryPoint.sh"]
CMD ["dotnet", "App.WebUI.dll"]
and my docker-compose:
services:
web:
container_name: web_container
depends_on:
- "postgres"
build:
context: .
dockerfile: Dockerfile.dedc
ports:
- "5000:80"
networks:
- de_network
postgres:
container_name: postgres_container
image: postgres:latest
build:
context: .
dockerfile: Dockerfile.pgdc
environment:
POSTGRES_PASSWORD: xxxxxxxx
POSTGRES_USER: xxxxxxxx
POSTGRES_DB: xxxxxxxx
ports:
- "5432:5432"
networks:
- de_network
networks:
de_network:
driver: bridge
and appEntryPoint.sh:
#!/bin/sh
echo "startup script is running"
chmod +x ./waitForIt.sh
./waitForIt.sh http://localhost:5432
exec "$@"
I have not included the wait-for-it.sh script because the error must occur before that point if the echo command is never reached. I must have set something up incorrectly, any help appreciated.