diff --git a/Dockerfile b/Dockerfile index 011eb034..833fb0a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,6 +49,8 @@ RUN ["mkdir", "/sql"] RUN ["dotnet", "tool", "install", "--global", "dotnet-ef"] RUN ["dotnet", "ef", "migrations", "bundle", "-r", "linux-x64", "--configuration", "Release", "-p", "TramsDataApi", "--context", "TramsDataApi.DatabaseModels.LegacyTramsDbContext", "--no-build", "-o", "/sql/migratelegacydb"] RUN ["dotnet", "ef", "migrations", "bundle", "-r", "linux-x64", "--configuration", "Release", "-p", "TramsDataApi", "--context", "TramsDataApi.DatabaseModels.TramsDbContext", "--no-build", "-o", "/sql/migratedb"] +COPY ./script/init-docker-entrypoint.sh /sql/entrypoint.sh +RUN ["chmod", "+x", "/sql/entrypoint.sh"] # ============================================== # Entity Framework: Migration Runner diff --git a/script/init-docker-entrypoint.sh b/script/init-docker-entrypoint.sh new file mode 100644 index 00000000..efc5b0c9 --- /dev/null +++ b/script/init-docker-entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# exit on failures +set -e +set -o pipefail + +while getopts "c" opt; do + case $opt in + c) + CONNECTION_STRING=$opt + ;; + *) + usage + ;; + esac +done + +/sql/migratedb -v --connection "$CONNECTION_STRING" +/sql/migratelegacydb -v --connection "$CONNECTION_STRING"