Add build and run profile for docker

main
Sambo Chea 1 year ago
parent 1b37995170
commit 0fbdcad9e4
  1. 2
      apps/demo/.env
  2. 2
      apps/demo/application-demo.yml
  3. 22
      apps/demo/build.sh
  4. 10
      apps/demo/move-file.sh
  5. 26
      apps/demo/run.sh
  6. 11
      apps/demo/variable.sh

@ -0,0 +1,2 @@
APP_PROFILE=demo
APP_DATA_DIR=/opt/cubetiq/data

@ -0,0 +1,2 @@
server:
port: ${APP_PORT:8090}

@ -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"

@ -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/

@ -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"

@ -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…
Cancel
Save