'ASP NET Core SQL Server Docker-Compose entry point bash script show errors on logs
I'm dockerizing an app but the entry point script doesn't work. The app couldn't perform CRUD actions and shows the "failed logging in with sa" error. I checked out the database because I suspect that the database didn't get created and yes, it didn't. So I thought the problem has to be the entry point script:
#!/bin/sh
set -e
until dotnet database update; do
echo "SQL Server is starting up"
sleep 1
done
echo "SQL Server is up - executing command"
dotnet database update
This script doesn't stop the app from building but it shows this in the log:
./Setup.sh: 1: ./Setup.sh: #!/bin/bash
not found
./Setup.sh: 2: ./Setup.sh:
not found
./Setup.sh: 3: set: Illegal option -
Here's the the docker file that's supposed to run the script above (named Migrations.Dockerfile):
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["Project/Project.csproj", "Project/"]
COPY Setup.sh Project/Setup.sh
RUN dotnet tool install --global dotnet-ef
RUN dotnet restore "./Project/Project.csproj"
COPY . .
WORKDIR "/src/Project"
RUN /root/.dotnet/tools/dotnet-ef migrations add InitialMigrations
RUN chmod +x ./Setup.sh
CMD /bin/sh ./Setup.sh
And here's the docker-compose.yml file:
version: '3.4'
services:
project:
image: ${DOCKER_REGISTRY-}project
build:
context: .
dockerfile: Project/Dockerfile
ports:
- "9080:80"
depends_on:
- migrations
- db
db:
image: mcr.microsoft.com/mssql/server:2019-latest
environment:
SA_PASSWORD: "W0WV3RYSTRONGPASSWORD!"
ACCEPT_EULA: "Y"
ports:
- "14331:1433"
depends_on:
- migrations
migrations:
build:
context: .
dockerfile: Migrations.Dockerfile
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
