build.bat
1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@echo off
TITLE 打包编译脚本
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:init
echo 选择编译打包的环境:
echo.
echo 1.dev &echo.
echo 2.prd &echo.
echo q.退出 &echo.&echo.&echo.
:input
set env=""
set/p input= 选择编译打包的环境:
if "%input%"=="1" (
set env="dev"
) else if "%input%"=="2" (
set env="prd"
) else if "%input%"=="Q" (
goto sc_exit
) else if "%input%"=="q" (
goto sc_exit
) else (
echo 输入错误请重试
echo.
goto init
)
echo 环境: %env%
echo.
echo 开始执行打包命令:&echo.
call mvn clean install package -Dmaven.test.skip=true -P=%env%
for /f "delims=" %%i in ('docker images ^| findstr pre/freya') do set a=%%i
if not "%a%"=="" (
call docker rmi pre/freya:pre
)
for /f "delims=" %%j in ('docker images ^| findstr freya') do set b=%%j
if not "%b%"=="" (
call docker tag freya:lastest pre/freya:pre
)
echo 开始编译docker镜像:&echo.
call docker build -t freya:lastest -f ./Dockerfile --no-cache .
echo 按任意键关闭窗口 &echo.
PAUSE >nul
:error
set error_code = 1
:sc_exit
exit