Add build and run profile for docker
This commit is contained in:
parent
1b37995170
commit
0fbdcad9e4
2
apps/demo/.env
Normal file
2
apps/demo/.env
Normal file
@ -0,0 +1,2 @@
|
||||
APP_PROFILE=demo
|
||||
APP_DATA_DIR=/opt/cubetiq/data
|
2
apps/demo/application-demo.yml
Normal file
2
apps/demo/application-demo.yml
Normal file
@ -0,0 +1,2 @@
|
||||
server:
|
||||
port: ${APP_PORT:8090}
|
22
apps/demo/build.sh
Normal file
22
apps/demo/build.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Get Execute Script Directory
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
|
||||
# shellcheck disable=SC2039
|
||||
source "$SCRIPT_DIR"/variable.sh
|
||||
|
||||
echo "===> Clean Gradle Build <==="
|
||||
bash gradlew clean
|
||||
|
||||
echo "===> Moving App File <==="
|
||||
bash "$SCRIPT_DIR"/move-file.sh
|
||||
|
||||
echo "===> Gradle Building Application <==="
|
||||
bash gradlew build -x test
|
||||
|
||||
echo "===> Docker Building Image <==="
|
||||
docker build . -t "$ROOT_HUB"
|
||||
|
||||
echo "===> Docker Pushing Image <==="
|
||||
docker push "$ROOT_HUB"
|
10
apps/demo/move-file.sh
Normal file
10
apps/demo/move-file.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get Execute Script Directory
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
|
||||
source "$SCRIPT_DIR"/variable.sh
|
||||
|
||||
echo "===> Copy & Replace Application Profile <==="
|
||||
rm -rf "$APP_MODULE_PATH"/src/main/resources/application-dev.yml
|
||||
cp -f "$SCRIPT_DIR"/application-"$APP_PROFILE".yml "$APP_MODULE_PATH"/src/main/resources/
|
26
apps/demo/run.sh
Normal file
26
apps/demo/run.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get Execute Script Directory
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
|
||||
# shellcheck disable=SC2039
|
||||
source "$SCRIPT_DIR"/variable.sh
|
||||
|
||||
CONTAINER_NAME="$CONTAINER"
|
||||
APP_DATA_DIR=$(passwd)/"$CONTAINER_NAME"
|
||||
|
||||
echo "===> Docker Pulling New Image <==="
|
||||
docker pull "$ROOT_HUB"
|
||||
|
||||
echo "===> Docker Removing Container <==="
|
||||
docker rm -f "$CONTAINER_NAME"
|
||||
|
||||
echo "===> Docker Run Container: $CONTAINER_NAME <==="
|
||||
docker run -d \
|
||||
-p "$EXPOSE_PORT":8090 \
|
||||
--env-file "$SCRIPT_DIR"/.env \
|
||||
-e HIBERNATE_DDL="${HIBERNATE_DDL:-update}" \
|
||||
-v "$APP_DATA_DIR"/data:/opt/cubetiq/data \
|
||||
--restart=always \
|
||||
--name "$CONTAINER_NAME" \
|
||||
"$ROOT_HUB"
|
11
apps/demo/variable.sh
Normal file
11
apps/demo/variable.sh
Normal file
@ -0,0 +1,11 @@
|
||||
# Build variables
|
||||
APP_MODULE_PATH=api
|
||||
APP_PROFILE=demo
|
||||
|
||||
# Docker Image variables
|
||||
VERSION=latest
|
||||
IMAGE=api-demo
|
||||
CONTAINER=$IMAGE
|
||||
REGISTRY=registry.kh.cubetiqs.com
|
||||
EXPOSE_PORT=8080
|
||||
ROOT_HUB=$REGISTRY/$IMAGE:$VERSION
|
Loading…
Reference in New Issue
Block a user