do everything dockerfile added
This commit is contained in:
@ -6,15 +6,19 @@ BUILD="0"
|
||||
EXECUTE="0"
|
||||
STAGE1="0"
|
||||
STAGE2="0"
|
||||
while getopts rxbh12 flag
|
||||
STAGE2_PRE_CONTAINER="0"
|
||||
KEEP="0"
|
||||
while getopts rxbh12ck flag
|
||||
do
|
||||
case "${flag}" in
|
||||
h)
|
||||
echo "1 ... generator stage 1 (implementation generator)";
|
||||
echo "2 ... generator stage 2 (openapi generator)";
|
||||
echo "r ... remove output directory";
|
||||
echo "k ... keep existing output directory";
|
||||
echo "b ... build after generating";
|
||||
echo "x ... execute after building";
|
||||
echo "c ... run stage in pre-started container";
|
||||
echo "h ... show help";
|
||||
|
||||
;;
|
||||
@ -33,6 +37,12 @@ do
|
||||
2)
|
||||
STAGE2="1"
|
||||
;;
|
||||
c)
|
||||
STAGE2_PRE_CONTAINER="1"
|
||||
;;
|
||||
k)
|
||||
KEEP="1"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@ -42,7 +52,7 @@ if [ "$REMOVE" = "1" ]; then
|
||||
fi
|
||||
|
||||
# safety measure
|
||||
if [ -d output ]; then
|
||||
if [ "$KEEP" = "0" -a -d output ]; then
|
||||
echo "output directory already exist"
|
||||
echo "remove manually and try again"
|
||||
exit 1
|
||||
@ -59,8 +69,15 @@ fi
|
||||
|
||||
if [ "$STAGE2" = "1" ]; then
|
||||
echo "generate server code and endpoint stubs from openapi.yaml"
|
||||
docker run -it --rm -v $PWD:/work -u $UID openapitools/openapi-generator-cli:v5.3.0 \
|
||||
generate -i /work/openapi.yaml -g aspnetcore -o /work/output \
|
||||
if [ "$STAGE2_PRE_CONTAINER" = "0" ]; then
|
||||
OPENAPI_GENERATOR_CMD="docker run -it --rm -v $PWD:/work -u $UID openapitools/openapi-generator-cli:v5.3.0"
|
||||
WORK_DIR="/work"
|
||||
else
|
||||
OPENAPI_GENERATOR_CMD="docker-entrypoint.sh"
|
||||
WORK_DIR="."
|
||||
fi
|
||||
$OPENAPI_GENERATOR_CMD \
|
||||
generate -i $WORK_DIR/openapi.yaml -g aspnetcore -o $WORK_DIR/output \
|
||||
--package-name $PACKAGE_NAME \
|
||||
--additional-properties="packageVersion=0.0.1,aspnetCoreVersion=5.0,operationIsAsync=false,operationResultTask=true,\
|
||||
generateBody=false,classModifier=abstract,operationModifier=abstract"
|
||||
@ -91,17 +108,18 @@ fi
|
||||
|
||||
if [ "$BUILD" = "1" ]; then
|
||||
echo "build service"
|
||||
cd output
|
||||
pushd output
|
||||
pushd src/$PACKAGE_NAME
|
||||
dotnet add package MySqlConnector --version 2.0.0
|
||||
popd
|
||||
sh build.sh
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ "$EXECUTE" = "1" ]; then
|
||||
echo "execute service"
|
||||
dotnet run -p src/$PACKAGE_NAME/$PACKAGE_NAME.csproj
|
||||
dotnet run -p output/src/$PACKAGE_NAME/$PACKAGE_NAME.csproj
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user