Commit 76afaa5a authored by zhangdd's avatar zhangdd

创建shell文件

Signed-off-by: default avatarzhangdd <86431843@qq.com>
parent 2c334a5d
......@@ -30,6 +30,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
......
#!/usr/bin/env bash
docker ps > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
echo "Docker is not running correctly!"
exit 1
fi
if [ $# -lt 1 ]; then
echo "Please specify spring active profile name!"
exit 1
fi
SPRING_PROFILE="$1"
parentGroupId=$(mvn help:evaluate -Dexpression=project.parent.groupId -q -DforceStdout)
hasParent=false
if [[ "$parentGroupId" == "com.aijiao"* || "$parentGroupId" == "com.schbrain"* ]]; then
hasParent=true
fi
if [ "$hasParent" == true ]; then
SERVICE=$(mvn help:evaluate -Dexpression=project.parent.artifactId -q -DforceStdout)
else
SERVICE=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
fi
if [ "$hasParent" == true ]; then
cd ..
fi
mvn -Dmaven.test.skip clean install
if [ $? -ne 0 ]; then
echo "Maven install failed!"
exit 1
fi
if [ "$hasParent" == true ]; then
cd -
fi
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
CONTAINER_NAME="$SERVICE"_"$SPRING_PROFILE"
docker stop "$CONTAINER_NAME"
docker rm "$CONTAINER_NAME"
existImageId=`docker images |grep "$SERVICE" |grep "$VERSION"_"$SPRING_PROFILE" |awk '{print $3}'`
if [ -n "$existImageId" ]; then
echo "Removing exist image: $existImageId"
docker rmi "$existImageId"
fi
if [ ! -d "target" ]; then
echo "target dir not exits!"
exit 1
fi
cd target
git archive -o dockerfiles.zip --format=zip --remote=git@gitlab.schbrain.com:schbrain-pub/dockerfiles.git 2.0:common
unzip -o dockerfiles.zip && rm -f dockerfiles.zip
TEST_MEM_OPTS=""
ONLINE_MEM_OPTS=""
if [[ "$SPRING_PROFILE" =~ "online" || "$SPRING_PROFILE" =~ "pre" ]]; then
if [ ! -z "$ONLINE_MEM_OPTS" ]; then
sed -i "" "s/MEM_OPTS=.*/MEM_OPTS=\"$ONLINE_MEM_OPTS\"/" run-app.sh
fi
else
if [ ! -z "$TEST_MEM_OPTS" ]; then
sed -i "" "s/MEM_OPTS=.*/MEM_OPTS=\"$TEST_MEM_OPTS\"/" run-app.sh
fi
fi
cd ..
profile=""
if [[ "$SPRING_PROFILE" =~ "online" || "$SPRING_PROFILE" =~ "pre" ]]; then
profile="-Ponline"
fi
mvn $profile -Dspring.profiles.active="$SPRING_PROFILE" dockerfile:build -U
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment