From 79c17ef7e55aa0b63e13226309912a1d1b6327df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atakan=20=C3=96zceviz?= Date: Tue, 2 Apr 2019 12:52:21 +0200 Subject: [PATCH] Create Dockerfile for migrations --- templates/service/database/Dockerfile | 21 +++++++++++++++++++++ templates/service/database/entrypoint.sh | 12 ++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 templates/service/database/Dockerfile create mode 100644 templates/service/database/entrypoint.sh diff --git a/templates/service/database/Dockerfile b/templates/service/database/Dockerfile new file mode 100644 index 0000000000..74bbe2c820 --- /dev/null +++ b/templates/service/database/Dockerfile @@ -0,0 +1,21 @@ +FROM microsoft/dotnet:2.2-sdk-alpine AS build +RUN apk add --no-cache bash +COPY . . + +WORKDIR /templates/service/host/IdentityServerHost +RUN dotnet restore -nowarn:msb3202,nu1503 +RUN dotnet build --no-restore -c Release + +WORKDIR /templates/service/host/MyCompanyName.MyProjectName.Host +RUN dotnet restore -nowarn:msb3202,nu1503 +RUN dotnet build --no-restore -c Release + +FROM build AS final +WORKDIR /src +COPY --from=build /templates/service/host/IdentityServerHost ./IdentityServerHost +COPY --from=build /templates/service/host/MyCompanyName.MyProjectName.Host ./MyCompanyName.MyProjectName.Host +COPY --from=build /templates/service/database/entrypoint.sh . +RUN /bin/bash -c "sed -i $'s/\r$//' entrypoint.sh" +RUN chmod +x ./entrypoint.sh + +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/templates/service/database/entrypoint.sh b/templates/service/database/entrypoint.sh new file mode 100644 index 0000000000..80f1b43dbc --- /dev/null +++ b/templates/service/database/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +cd IdentityServerHost +export ConnectionStrings__Default=$IdentityServerConnectionString + +until dotnet ef database update --no-build; do +>&2 echo "SQL Server is starting up" +sleep 1 +done + +export ConnectionStrings__Default=$MyProjectNameConnectionString +cd MyCompanyName.MyProjectName.Host && dotnet ef database update --no-build \ No newline at end of file