Skip to content

Instantly share code, notes, and snippets.

@fabri1983
Last active September 11, 2019 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabri1983/ffcc2a8c7323306b07a83c0001105578 to your computer and use it in GitHub Desktop.
Save fabri1983/ffcc2a8c7323306b07a83c0001105578 to your computer and use it in GitHub Desktop.
Script docker-build expects two arguments: artifact name (war filename without extension) and docker tag name.
@ECHO OFF
IF "%1"=="" (
GOTO NO_ARGS
)
IF "%2"=="" (
GOTO NO_ARGS
)
IF NOT "%3"=="" (
GOTO WRONG_ARGS
)
GOTO ACTION
:NO_ARGS
ECHO No arguments supplied. You need to specify war final name (without .war) and tag name
GOTO DONE
:WRONG_ARGS
ECHO Wrong number of arguments. You need to specify war final name (without .war) and tag name
GOTO DONE
:ACTION
ECHO -----------------------------
ECHO Decompressing %1.war
ECHO -----------------------------
RMDIR /Q /S target\docker-workdir > NUL 2>&1
MKDIR target\docker-workdir
:: if folder target\%1 exists then copy the content to docker-workdir
IF EXIST target\%1\ (
ECHO No need to decompress war, copying files from target\%1 to target\docker-workdir
XCOPY /Q /E target\%1 target\docker-workdir
) ELSE (
:: else decompress war file
CD target\docker-workdir
jar -xf ..\%1.war
CD ..\..
)
ECHO -----------------------------
ECHO Building Docker image
ECHO -----------------------------
:: create Docker image
docker image build ^
--build-arg DEPENDENCIES=docker-workdir ^
--build-arg API_NAME=%1 ^
-f target/Dockerfile -t fabri1983dockerid/%1:%2 ./target
ECHO -----------------------------
ECHO Finished!
ECHO -----------------------------
:DONE
EXIT /b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment