-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michele Mondelli
committed
Aug 1, 2022
1 parent
05d7b3f
commit b9a0fd1
Showing
17 changed files
with
346 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
QUOTEDCMD=() | ||
for token in "$@"; do | ||
QUOTEDCMD+=($(printf "%q" "$token")) | ||
|
||
for var in "$@" | ||
do | ||
PARAMS="$PARAMS ${var}" | ||
done | ||
CMD="${QUOTEDCMD[*]}" | ||
if [[ -z "$CMD" ]] | ||
then | ||
CMD="sh" | ||
fi | ||
|
||
if [[ -t 1 ]] ; then OPTS=""; else OPTS="-T"; fi | ||
|
||
docker-compose exec -u $(id -u):$(id -g) ${OPTS} app /bin/sh -c "${CMD}" | ||
docker-compose exec -u $(id -u):$(id -g) ${OPTS} app /bin/bash -c "${PARAMS}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
PWD=$(pwd) | ||
while [[ "$PWD" != "" && ! -e "$PWD/.bmeme" ]]; do | ||
PWD=${PWD%/*} | ||
done | ||
|
||
FOUND=$PWD | ||
|
||
if [[ "${FOUND}" = "" ]]; then | ||
echo "Unable to found parent bmeme project!" | ||
exit -1 | ||
fi | ||
|
||
ORIG_DIR=$(pwd) | ||
REL_DIR=${ORIG_DIR#"$FOUND"} | ||
|
||
set -e | ||
QUOTEDCMD=() | ||
for token in "$@"; do | ||
QUOTEDCMD+=($(printf "%q" "$token")) | ||
done | ||
CMD="${QUOTEDCMD[*]}" | ||
|
||
pushd ${FOUND} > /dev/null | ||
.bmeme/bin/app cd ".${REL_DIR}" \; ${CMD} | ||
popd > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
source "${SCRIPT_DIR}/../common/lib.sh" | ||
|
||
if [[ "$1" == "descr" ]]; then | ||
echo -n "Create and initialize application" | ||
exit 0 | ||
fi | ||
|
||
if [[ "$1" == "run" ]]; then | ||
|
||
echo "" | ||
echo -e "Setting up ${CG}docker environment${CN} ..." | ||
echo "" | ||
echo "${LOGPREFIX} CMD docker-compose build --build-arg FIX_UID=$(id -u) --build-arg FIX_GID=$(id -g)" >> ${LOGFILE} | ||
docker-compose build --build-arg FIX_UID=$(id -u) --build-arg FIX_GID=$(id -g) 2>&1 >> ${LOGFILE} | ||
echo "${LOGPREFIX} CMD docker-compose up -d" >> ${LOGFILE} | ||
docker-compose up -d 2>&1 >> ${LOGFILE} | ||
|
||
echo "" | ||
if [[ ":$PATH:" == *":$LOCAL_PATH:"* ]]; then | ||
echo -e "Your ${CG}\$PATH${CN} is correctly set" | ||
else | ||
echo -e "Your ${CG}\$PATH${CN} is not configured." | ||
echo "" | ||
echo -e "Run: ${CY}eval \$(${0} env)${CN}" | ||
echo "" | ||
fi | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
source "${SCRIPT_DIR}/../common/lib.sh" | ||
|
||
if [[ "$1" == "descr" ]]; then | ||
echo -n "Clean docker environment" | ||
exit 0 | ||
fi | ||
|
||
if [[ "$1" == "run" ]]; then | ||
echo "" | ||
echo -e "Cleaning ${CG}docker environment${CN} ..." | ||
echo "" | ||
echo "${LOGPREFIX} CMD docker-compose down -v" >> ${LOGFILE} | ||
docker-compose down -v 2>&1 >> ${LOGFILE} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
source "${SCRIPT_DIR}/../common/lib.sh" | ||
|
||
if [[ "$1" == "descr" ]]; then | ||
echo -n "Check system requirements" | ||
exit 0 | ||
fi | ||
|
||
if [[ "$1" == "run" ]]; then | ||
echo "" | ||
echo -e "Checking ${CG}system requirements${CN} ..." | ||
echo "" | ||
echo "${LOGPREFIX} CMD docker --version" >> ${LOGFILE} | ||
docker --version 2>&1 >> ${LOGFILE} | ||
echo "${LOGPREFIX} CMD docker-compose --version" >> ${LOGFILE} | ||
docker-compose --version 2>&1 >> ${LOGFILE} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
source "${SCRIPT_DIR}/../common/lib.sh" | ||
|
||
if [[ "$1" == "descr" ]]; then | ||
echo -n "Start docker environment" | ||
exit 0 | ||
fi | ||
|
||
if [[ "$1" == "run" ]]; then | ||
echo "" | ||
echo -e "Starting ${CG}docker environment${CN} ..." | ||
echo "" | ||
echo "${LOGPREFIX} CMD docker-compose start" >> ${LOGFILE} | ||
docker-compose start 2>&1 >> ${LOGFILE} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
source "${SCRIPT_DIR}/../common/lib.sh" | ||
|
||
if [[ "$1" == "descr" ]]; then | ||
echo -n "Show docker environment status" | ||
exit 0 | ||
fi | ||
|
||
if [[ "$1" == "run" ]]; then | ||
echo "" | ||
echo -e "Checking ${CG}docker environment${CN} status ..." | ||
echo "" | ||
echo "${LOGPREFIX} CMD docker-compose ps" >> ${LOGFILE} | ||
docker-compose ps | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
source "${SCRIPT_DIR}/../common/lib.sh" | ||
|
||
if [[ "$1" == "descr" ]]; then | ||
echo -n "Stop docker environment" | ||
exit 0 | ||
fi | ||
|
||
if [[ "$1" == "run" ]]; then | ||
echo "" | ||
echo -e "Stopping your ${CG}docker environment${CN} ..." | ||
echo "" | ||
echo "${LOGPREFIX} CMD docker-compose stop" >> ${LOGFILE} | ||
docker-compose stop 2>&1 >> ${LOGFILE} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CN="\\033[0m" | ||
CR="\\033[91m" | ||
CG="\\033[92m" | ||
CY="\\033[93m" | ||
CB="\\033[94m" | ||
CT="\\033[37m" | ||
TB="\\033[1m" | ||
|
||
LIB_SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
BASE_PRJ_DIR=$(realpath "${LIB_SCRIPT_DIR}/../../..") | ||
if test -f "${BASE_PRJ_DIR}/.env"; then | ||
source "${BASE_PRJ_DIR}/.env" | ||
fi | ||
APP_DIR="${BASE_PRJ_DIR}/app" | ||
|
||
LOCAL_PATH="${BASE_PRJ_DIR}/.bmeme/bin" | ||
C_BIN="${BASE_PRJ_DIR}/.bmeme/bin/c" | ||
LOGDIR="${BASE_PRJ_DIR}/.bmeme/log" | ||
DATE=$(date +%Y-%m-%d_%H-%M-%S) | ||
LOGFILE="${LOGDIR}/configure.log" | ||
LOGPREFIX=">>>> " | ||
|
||
log_begin() { | ||
echo "" >>${LOGFILE} | ||
echo "${LOGPREFIX} SCRIPT EXECUTED" >>${LOGFILE} | ||
echo "${LOGPREFIX} Bin: ${0}" >>${LOGFILE} | ||
echo "${LOGPREFIX} Params: ${@}" >>${LOGFILE} | ||
echo "${LOGPREFIX} Time: $(date +'%Y-%m-%d %H:%M:%S')" >>${LOGFILE} | ||
echo "" >>${LOGFILE} | ||
} | ||
|
||
log_end() { | ||
echo "" >>${LOGFILE} | ||
echo "${LOGPREFIX} SCRIPT TERMINATED" >>${LOGFILE} | ||
echo "${LOGPREFIX} Time: $(date +'%Y-%m-%d %H:%M:%S')" >>${LOGFILE} | ||
echo "" >>${LOGFILE} | ||
} | ||
|
||
show_cmd_error() { | ||
echo -e "${TB}${CR}ERROR${CN}" | ||
echo "" | ||
echo -e "See ${CB}logfile${CN} for details: " | ||
echo -e "\t${CY}tail -f ${LOGFILE}${CN}" | ||
echo "" | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM maven:3.8-openjdk-11-slim | ||
|
||
ARG FIX_UID | ||
ARG FIX_GID | ||
|
||
RUN groupadd -g $FIX_GID -o maven && \ | ||
useradd -m -u $FIX_UID -g $FIX_GID -d /usr/src/app -o -s /bin/bash maven | ||
|
||
USER maven |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
version: "3.4" | ||
services: | ||
app: | ||
image: bmeme/java-dev:3.8.3-jdk-11-openj9 | ||
build: | ||
context: config/docker | ||
dockerfile: dockerfiles/Dockerfile.app | ||
entrypoint: /bin/sleep infinity | ||
working_dir: /usr/src/app/ | ||
volumes: | ||
- "../:/usr/src/app:cached" | ||
environment: | ||
- TERM=xterm-256color | ||
- MAVEN_CONFIG=/usr/src/app/.cache/.m2 | ||
- DNSDOCK_ALIAS=${PROJECT_NAME}.${PROJECT_VENDOR}.docker | ||
- DNSDOCK_ALIAS=app.${PROJECT_NAME}.${PROJECT_VENDOR}.docker | ||
- VIRTUAL_PORT=8090 | ||
- VIRTUAL_HOST=app.${PROJECT_NAME}.${PROJECT_VENDOR}.docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# Custom variables. | ||
PROJECT_NAME=__PROJECT__ | ||
PROJECT_VENDOR=__VENDOR__ | ||
PROJECT_NAME=@@@PROJECT@@@ | ||
PROJECT_VENDOR=@@@VENDOR@@@ | ||
|
||
# Compose CLI environment variables. | ||
# @see https://docs.docker.com/compose/reference/envvars | ||
COMPOSE_PROJECT_NAME=${PROJECT_NAME}_${PROJECT_VENDOR} | ||
COMPOSE_PROJECT_NAME=@@@PROJECT@@@_@@@VENDOR@@@ | ||
COMPOSE_FILE=.bmeme/docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.