Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
063c943
Run up command on module add/remove
lexuzieel Apr 18, 2021
a17ef40
Add --no-chown flag to modules command
lexuzieel Apr 18, 2021
1772609
Silence helper scripts by default
lexuzieel Apr 18, 2021
df5a732
Update up.sh
lexuzieel Apr 19, 2021
f07db75
Update version.sh
lexuzieel Apr 19, 2021
236ba9d
Update process.sh
lexuzieel Apr 19, 2021
133bc01
Update process.sh
lexuzieel Apr 19, 2021
05b69cb
Merge branch 'v0.6.1' of https://github.com/docker-blueprint/core int…
lexuzieel Apr 20, 2021
c973bb6
Add .gitignore
lexuzieel Apr 20, 2021
d8f86fb
Update entrypoint.sh
lexuzieel Apr 20, 2021
c48a133
Fix empty blueprint hash on compile
lexuzieel Apr 20, 2021
45a504b
Make initial compilation silent
lexuzieel Apr 20, 2021
3ca6476
Update temporary file lifetime
lexuzieel Apr 20, 2021
92b0d9a
Revert "Update temporary file lifetime"
lexuzieel Apr 20, 2021
5bc1d85
Do not remove temporary blueprint
lexuzieel Apr 20, 2021
4596428
Update run.sh
lexuzieel Apr 20, 2021
81a5693
Add upgrade command
lexuzieel Apr 20, 2021
cdfc454
Update install.sh
lexuzieel Apr 20, 2021
5c8d945
Update installer
lexuzieel Apr 20, 2021
fe92c49
Refactor out yq install script
lexuzieel Apr 20, 2021
1ce93e8
Add docker install script
lexuzieel Apr 20, 2021
f057b00
Add docker-compose installer
lexuzieel Apr 20, 2021
3fa1ded
Embed install scripts into install.sh
lexuzieel Apr 20, 2021
9d005dc
Update install.sh
lexuzieel Apr 20, 2021
695849b
Revert "Update install.sh"
lexuzieel Apr 20, 2021
2ed1dbb
Update install.sh
lexuzieel Apr 20, 2021
c3a351a
Update install.sh
lexuzieel Apr 20, 2021
89c4911
Update install.sh
lexuzieel Apr 20, 2021
7432034
Explicitly specify REPLY on read
lexuzieel Apr 20, 2021
f102af3
Update install.sh
lexuzieel Apr 20, 2021
f164331
Make docker rootless on Ubuntu
lexuzieel Apr 20, 2021
1175189
Fix installer checks
lexuzieel Apr 20, 2021
96d4def
Update install.sh
lexuzieel Apr 20, 2021
c68cfe6
Update install.sh
lexuzieel Apr 20, 2021
ebdae54
Update install.sh
lexuzieel Apr 20, 2021
43c144b
Update install.sh
lexuzieel Apr 20, 2021
839047b
Update install.sh
lexuzieel Apr 20, 2021
97e746d
Update project rebuilding
lexuzieel Apr 21, 2021
f4f92d1
Update get-script-vars.sh
lexuzieel Apr 21, 2021
eff8165
Update install.sh
lexuzieel Apr 21, 2021
9391fc2
Update pull command
lexuzieel Apr 21, 2021
f59cd8c
Update upgrade.sh
lexuzieel Apr 22, 2021
ac728da
Update upgrade.sh
lexuzieel Apr 22, 2021
0d2ee51
Fix sync command
lexuzieel Apr 27, 2021
756c5ad
Update pull.sh
lexuzieel Apr 29, 2021
173cc7a
Update pull.sh
lexuzieel Apr 29, 2021
d5d656d
Update pull.sh
lexuzieel Apr 29, 2021
19c9f35
Update pull.sh
lexuzieel Apr 29, 2021
8fb6760
Update pull.sh
lexuzieel Apr 29, 2021
668c3e4
Update pull.sh
lexuzieel Apr 29, 2021
54523fa
Update yq.sh
lexuzieel Apr 29, 2021
e5aeb74
Update pull.sh
lexuzieel Apr 29, 2021
daaf9ea
Update pull.sh
lexuzieel Apr 29, 2021
893c7b0
Update pull.sh
lexuzieel May 9, 2021
2252f68
Update upgrade.sh
lexuzieel May 10, 2021
1acd1f4
Merge branch 'v0.6.1' of https://github.com/docker-blueprint/core int…
lexuzieel May 10, 2021
e746683
Update up.sh
lexuzieel May 16, 2021
c9008fd
Update up.sh
lexuzieel May 16, 2021
9f625c8
Update pull.sh
lexuzieel May 16, 2021
c539703
Update sync.sh
lexuzieel May 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tmp/
cache/
2 changes: 1 addition & 1 deletion commands/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ non_debug_print " ${GREEN}done${RESET}\n"
# export SCRIPT_VARS
# export SCRIPT_VARS_ENV
# export SCRIPT_VARS_BUILD_ARGS
source "$ROOT_DIR/includes/get-script-vars.sh"
SILENT=false source "$ROOT_DIR/includes/get-script-vars.sh"

#
# Build docker-compose.yml
Expand Down
6 changes: 3 additions & 3 deletions commands/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ if ! $MODE_QUIET; then
if ! $MODE_FORCE; then
printf "Do you want to rebuild the project? (run with ${FLG_COL}--force${RESET} to always build)\n"
printf "${YELLOW}WARNING${RESET}: This will ${RED}overwrite${RESET} existing docker files [y/N] "
read -n 1 -r
read -n 1 -r REPLY
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
bash $ENTRYPOINT build --force
bash $ENTRYPOINT up --force
fi
else
bash $ENTRYPOINT build --force
bash $ENTRYPOINT up --force
fi
fi
6 changes: 3 additions & 3 deletions commands/lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ if ! $MODE_NO_BUILD; then
if ! $MODE_FORCE; then
printf "Do you want to rebuild the project? (run with ${FLG_COL}--force${RESET} to always build)\n"
printf "${YELLOW}WARNING${RESET}: This will ${RED}overwrite${RESET} existing docker files [y/N] "
read -n 1 -r
read -n 1 -r REPLY
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
bash $ENTRYPOINT build --force
bash $ENTRYPOINT up --force
fi
else
bash $ENTRYPOINT build --force
bash $ENTRYPOINT up --force
fi
fi
101 changes: 54 additions & 47 deletions commands/modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ MODE_NO_BUILD=false
MODE_NO_SCRIPTS=false
MODE_PRINT_ACTIVE_ONLY=false

UP_ARGS=()

while [[ "$#" -gt 0 ]]; do
case $1 in
-h | --help)
Expand All @@ -35,6 +37,9 @@ while [[ "$#" -gt 0 ]]; do
printf " ${FLG_COL}-a${RESET}, ${FLG_COL}--active${RESET}"
printf "\t\tOnly list active modules\n"

printf " ${FLG_COL}--no-chown${RESET}"
printf "\t\t\tPass --no-chown to 'sync' command\n"

printf " ${FLG_COL}--no-build${RESET}"
printf "\t\t\tDon't attempt to build\n"

Expand All @@ -51,9 +56,14 @@ while [[ "$#" -gt 0 ]]; do
;;
--no-build)
MODE_NO_BUILD=true
UP_ARGS+=("--no-build")
;;
--no-scripts)
MODE_NO_SCRIPTS=true
UP_ARGS+=("--no-scripts")
;;
--no-chown)
UP_ARGS+=("--no-chown")
;;
-a | --active)
MODE_PRINT_ACTIVE_ONLY=true
Expand Down Expand Up @@ -99,7 +109,7 @@ source "$ROOT_DIR/includes/blueprint/populate_env.sh" ""

yq_read_array MODULES_TO_LOAD 'modules'
EXPLICIT_MODULES_LIST=(${MODULES_TO_LOAD[@]})
source "$ROOT_DIR/includes/resolve-dependencies.sh" ${MODULES_TO_LOAD[@]}
SILENT=true source "$ROOT_DIR/includes/resolve-dependencies.sh" ${MODULES_TO_LOAD[@]}
ACTIVE_MODULES_LIST=(${MODULES_TO_LOAD[@]})

MODULES_LIST=()
Expand Down Expand Up @@ -221,6 +231,7 @@ else
done
fi

script_paths=()
needs_rebuild=false

for MODULE in "${MODULES[@]}"; do
Expand All @@ -247,63 +258,59 @@ for MODULE in "${MODULES[@]}"; do
;;
esac

if ! $MODE_QUIET && ! $MODE_NO_BUILD && $needs_rebuild; then
if ! $MODE_FORCE; then
printf "Do you want to rebuild the project? (run with ${FLG_COL}--force${RESET} to always build)\n"
printf "${YELLOW}WARNING${RESET}: This will ${RED}overwrite${RESET} existing docker files [y/N] "
read -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
bash $ENTRYPOINT build --force
else
continue
fi
else
bash $ENTRYPOINT build --force
fi
# Add base blueprint module scripts first
path="$BLUEPRINT_DIR/modules/$MODULE/scripts/$ACTION.sh"
if [[ -f "$path" ]]; then
script_paths+=("$path")
fi

if ! $MODE_NO_SCRIPTS; then
script_paths=()

# Add base blueprint module scripts first
path="$BLUEPRINT_DIR/modules/$MODULE/scripts/$ACTION.sh"
if [[ -f "$path" ]]; then
script_paths+=("$path")
fi
# Then add environment module scripts
path="$ENV_DIR/modules/$MODULE/scripts/$ACTION.sh"
if [[ -f "$path" ]]; then
script_paths+=("$path")
fi
done

# Then add environment module scripts
path="$ENV_DIR/modules/$MODULE/scripts/$ACTION.sh"
if [[ -f "$path" ]]; then
script_paths+=("$path")
if ! $MODE_QUIET && ! $MODE_NO_BUILD && $needs_rebuild; then
if ! $MODE_FORCE; then
printf "Do you want to rebuild the project? (run with ${FLG_COL}--force${RESET} to always build)\n"
printf "${YELLOW}WARNING${RESET}: This will ${RED}overwrite${RESET} existing docker files [y/N] "
read -n 1 -r REPLY
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
bash $ENTRYPOINT up --force ${UP_ARGS[@]}
fi
else
bash $ENTRYPOINT up --force ${UP_ARGS[@]}
fi
fi

status=0
if ! $MODE_NO_SCRIPTS; then
status=0

# export SCRIPT_VARS
# export SCRIPT_VARS_ENV
# export SCRIPT_VARS_BUILD_ARGS
source "$ROOT_DIR/includes/get-script-vars.sh"
# export SCRIPT_VARS
# export SCRIPT_VARS_ENV
# export SCRIPT_VARS_BUILD_ARGS
source "$ROOT_DIR/includes/get-script-vars.sh"

for path in "${script_paths[@]}"; do
printf "Running script for module '$MODULE'...\n"
debug_print "Running script: ${path#$BLUEPRINT_DIR/}"
for path in "${script_paths[@]}"; do
printf "Running script for module '$MODULE'...\n"
debug_print "Running script: ${path#$BLUEPRINT_DIR/}"

PROGRAM="$(source "$ROOT_DIR/includes/script/prepare.sh" "$(cat "$path")")"
PROGRAM="$(source "$ROOT_DIR/includes/script/prepare.sh" "$(cat "$path")")"

command="bash -c \"$PROGRAM\""
bash $ENTRYPOINT "${SCRIPT_VARS_ENV[@]}" $DEFAULT_SERVICE exec "$command"
command="bash -c \"$PROGRAM\""
bash $ENTRYPOINT "${SCRIPT_VARS_ENV[@]}" $DEFAULT_SERVICE exec "$command"

status=$?

if [[ $status > 0 ]]; then
break
fi
done
status=$?

if [[ $status > 0 ]]; then
printf -- "${RED}ERROR${RESET}: Module script returned non-zero code: ${path#$BLUEPRINT_DIR/}\n"
exit $status
break
fi
done

if [[ $status > 0 ]]; then
printf -- "${RED}ERROR${RESET}: Module script returned non-zero code: ${path#$BLUEPRINT_DIR/}\n"
exit $status
fi
done
fi
4 changes: 1 addition & 3 deletions commands/new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fi
if ! [[ -f "$PWD/$PROJECT_BLUEPRINT_FILE" ]]; then

# export BLUEPRINT_PATH
SILENT=false source "$ROOT_DIR/includes/blueprint/compile.sh" "$BLUEPRINT"
SILENT=true source "$ROOT_DIR/includes/blueprint/compile.sh" "$BLUEPRINT"
debug_switch_context "NEW"

# Populate project blueprint
Expand Down Expand Up @@ -195,8 +195,6 @@ if ! [[ -f "$PWD/$PROJECT_BLUEPRINT_FILE" ]]; then
fi
done

rm -f "$BLUEPRINT_PATH"

fi

if $FORCE_GENERATE; then
Expand Down
2 changes: 1 addition & 1 deletion commands/process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi
while [[ "$#" -gt 0 ]]; do
case $1 in
-h | --help)
printf "${CMD_COL}process${RESET} [${FLG_COL}options${RESET}] ${ARG_COL}<path>${RESET}"
printf "${CMD_COL}process${RESET} ${ARG_COL}<path>${RESET} [${FLG_COL}options${RESET}]"
printf "\t"
printf "Preprocess dockerfile template from the blueprint\n"

Expand Down
58 changes: 48 additions & 10 deletions commands/pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# Function mode allows to use this command in conjunction
# with others (i.e. create).

debug_switch_context "PULL"

#
# Read arguments
#
Expand All @@ -30,8 +32,9 @@ MODE_GET_QUALIFIED=false
while [[ "$#" -gt 0 ]]; do
case $1 in
-h | --help)
printf "${CMD_COL}pull${RESET} ${ARG_COL}<blueprint>${RESET} [${FLG_COL}options${RESET}]"
printf "\tDownload the latest version of blueprint\n"
if [[ "$WITH_USAGE" -eq 1 ]]; then printf "Usage:\n"; fi
printf "${CMD_COL}pull${RESET} [${ARG_COL}<blueprint>${RESET}] [${FLG_COL}options${RESET}]"
printf "\tDownload the latest version of a blueprint\n"

printf " ${FLG_COL}--clean${RESET}"
printf "\t\t\tRemove already existing copy of a blueprint and install fresh download\n"
Expand All @@ -49,21 +52,34 @@ while [[ "$#" -gt 0 ]]; do
MODE_GET_QUALIFIED=true
;;
*)
if [[ -z "$1" ]]; then
printf "Usage: "
bash $ENTRYPOINT pull --help
exit 1
fi

if [[ -z $BLUEPRINT ]]; then
BLUEPRINT=$1
BLUEPRINT="$1"
fi
;;
esac

shift
done

if [[ -z "$BLUEPRINT" ]]; then
! $AS_FUNCTION && debug_print "No blueprint name provided - trying to resolve from $PROJECT_BLUEPRINT_FILE..."

# Try to read blueprint name from docker-blueprint.yml
if [[ -f "$PROJECT_BLUEPRINT_FILE" ]]; then
yq_read_value BLUEPRINT 'from'
if [[ -z "$BLUEPRINT" ]]; then
! $AS_FUNCTION && printf "${RED}ERROR${RESET}: Unable to resolve blueprint from project blueprint file.\n\n"
WITH_USAGE=1 bash $ENTRYPOINT pull --help
exit 1
else
! $AS_FUNCTION && debug_print "Found blueprint '$BLUEPRINT' in project blueprint file"
fi
else
bash $ENTRYPOINT pull --help
exit 1
fi
fi

#
# Parse blueprint name and branch
#
Expand Down Expand Up @@ -174,7 +190,14 @@ else
else
PREVIOUS_DIR="$PWD"
cd "$BLUEPRINT_DIR"
git fetch >/dev/null
git checkout master &>/dev/null
git pull &>/dev/null
if [[ $? -gt 0 ]]; then
cd "$PREVIOUS_DIR"
printf "${RED}ERROR${RESET}: Blueprint directory has local changes\n"
printf "You can clear local changes with 'docker-blueprint pull --clean'\n"
exit 1
fi
cd "$PREVIOUS_DIR"
fi
fi
Expand Down Expand Up @@ -222,6 +245,21 @@ if ! $MODE_DRY_RUN; then
fi
fi

yq_read_value CHECKPOINT 'version'

# Set the blueprint repository to the version specified.
# This allows to always safely reproduce previous versions of the blueprint.
if [[ -n "$CHECKPOINT" ]]; then
if ! $AS_FUNCTION; then
printf "${BLUE}INFO${RESET}: Version lock applied: ${CYAN}$CHECKPOINT${RESET}\n"
git checkout $CHECKPOINT 2>/dev/null
else
git checkout $CHECKPOINT &>/dev/null
fi
else
! $AS_FUNCTION && printf "${BLUE}INFO${RESET}: No version lock found - using latest version.\n"
fi

cd $PREVIOUS_DIR

fi
Expand Down
5 changes: 3 additions & 2 deletions commands/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ elif [[ -n "$PROJECT_CONTEXT" ]]; then
debug_print "Using DEFAULT context: $PROJECT_CONTEXT"
fi

debug_print "Program to run:\n%s\n" "$PROGRAM"

# Escape backslashes first
PROGRAM="$(echo "$PROGRAM" | sed -E 's/\\/\\\\/g')"
# Escape variable sign ($) to execute it inside runtime
Expand All @@ -149,10 +151,9 @@ PROGRAM="$(echo "$PROGRAM" | sed -E 's/"/\\"/g')"

command="env ${ENV_PREFIX[*]} $RUNTIME \"$PROGRAM\""

debug_print "Program to run:\n$PROGRAM"
debug_print "Running..."

bash $ENTRYPOINT ${ENTRYPOINT_ARGS[*]} -- $SERVICE $COMMAND_VERB "$command"
bash $ENTRYPOINT ${ENTRYPOINT_ARGS[*]} $SERVICE $COMMAND_VERB "$command"

for key in "${ENVIRONMENT_KEYS[@]}"; do
unset $key
Expand Down
20 changes: 17 additions & 3 deletions commands/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ shift

MODE_NO_CHOWN=false
MODE_SKIP_USER=false
MODE_SKIP_ENV=false

while [[ "$#" -gt 0 ]]; do
case $1 in
Expand All @@ -28,11 +29,13 @@ while [[ "$#" -gt 0 ]]; do
;;
--no-chown)
MODE_NO_CHOWN=true

;;
--skip-user)
MODE_SKIP_USER=true
;;
--skip-env)
MODE_SKIP_ENV=true
;;
esac

shift
Expand Down Expand Up @@ -64,12 +67,23 @@ if ! $MODE_SKIP_USER && [[ -n "$SYNC_USER" ]]; then
fi
fi

if [[ -f .env ]]; then
if ! $MODE_SKIP_ENV && [[ -f .env ]]; then
debug_print "Found .env file in the project directory"
debug_print "Looking for docker-compose files..."

files=(
docker-compose.$PROJECT_CONTEXT.y*ml
docker-compose.y*ml
)

temp_file="$TEMP_DIR/docker-compose.env"
for file in docker-compose*; do
touch "$temp_file"

for file in ${files[@]}; do
if [[ ! -f "$file" ]]; then
continue
fi

debug_print "Found file: $file"

if [[ ! -f "$temp_file" ]]; then
Expand Down
Loading