From c60b752c08f506be2191538f96c1f3015d45552e Mon Sep 17 00:00:00 2001 From: ukkopahis <95980324+ukkopahis@users.noreply.github.com> Date: Tue, 3 May 2022 06:30:09 +0300 Subject: [PATCH] Fix .bash_aliases to not to assume ~/IOTstack * must change the directory, as using the '-f' flag would ignore a possibly existing `docker-compose.override.yml' * using remove-orphans to automatically adjust when services are removed from the stack --- .bash_aliases | 15 ++++++++------- docs/Basic_setup/Docker.md | 25 ++++++++++++++----------- mkdocs.yml | 1 + 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index a8d1d767a..05b57d476 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,7 +1,8 @@ -alias iotstack_up="docker-compose -f ~/IOTstack/docker-compose.yml up -d" -alias iotstack_down="docker-compose -f ~/IOTstack/docker-compose.yml down" -alias iotstack_start="docker-compose -f ~/IOTstack/docker-compose.yml start" -alias iotstack_stop="docker-compose -f ~/IOTstack/docker-compose.yml stop" -alias iotstack_update="docker-compose -f ~/IOTstack/docker-compose.yml pull" -alias iotstack_build="docker-compose -f ~/IOTstack/docker-compose.yml build" - +IOTSTACK_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +alias iotstack_up="cd "$IOTSTACK_HOME" && docker-compose up -d --remove-orphans" +alias iotstack_down="cd "$IOTSTACK_HOME" && docker-compose down --remove-orphans" +alias iotstack_start="cd "$IOTSTACK_HOME" && docker-compose start" +alias iotstack_stop="cd "$IOTSTACK_HOME" && docker-compose stop" +alias iotstack_pull="cd "$IOTSTACK_HOME" && docker-compose pull" +alias iotstack_build="cd "$IOTSTACK_HOME" && docker-compose build --pull --no-cache" +alias iotstack_update_docker_images='f(){ iotstack_pull "$@" && iotstack_build "$@" && iotstack_up --build "$@"; }; f' diff --git a/docs/Basic_setup/Docker.md b/docs/Basic_setup/Docker.md index de97a8c72..b676a1c12 100644 --- a/docs/Basic_setup/Docker.md +++ b/docs/Basic_setup/Docker.md @@ -34,9 +34,9 @@ concern. Then you can enable log-rotation by either: ## Aliases -Bash aliases for stopping and starting the stack are in the file -`.bash_aliases`. To use them immediately and in future logins, run in a -console: +Bash aliases for stopping and starting the stack and other common operations +are in the file `.bash_aliases`. To use them immediately and in future logins, +run in a console: ``` console $ source ~/IOTstack/.bash_aliases @@ -45,13 +45,16 @@ $ echo ". ~/IOTstack/.bash_aliases" >> ~/.profile These commands no longer need to be executed from the IOTstack directory and can be executed in any directory -``` console -alias iotstack_up="docker-compose -f ~/IOTstack/docker-compose.yml up -d" -alias iotstack_down="docker-compose -f ~/IOTstack/docker-compose.yml down" -alias iotstack_start="docker-compose -f ~/IOTstack/docker-compose.yml start" -alias iotstack_stop="docker-compose -f ~/IOTstack/docker-compose.yml stop" -alias iotstack_update="docker-compose -f ~/IOTstack/docker-compose.yml pull" -alias iotstack_build="docker-compose -f ~/IOTstack/docker-compose.yml build" +``` bash title=".bash_aliases" +--8<-- ".bash_aliases" ``` -You can now type `iotstack_up`, they even accept additional parameters `iotstack_stop portainer` +You can now type `iotstack_up`. The aliases also accept additional parameters, +e.g. `iotstack_stop portainer`. + +The `iotstack_update_docker_images` alias will [update docker images]( +http://localhost:8000/Updates/#recommended-update-only-docker-images) to newest +released images, build and recreate containers. Do note that using this will +result in a broken containers from time to time, as upstream may release faulty +docker images. Have proper backups, or be prepared to manually pin a previous +release build by editing `docker-compose.yml`. diff --git a/mkdocs.yml b/mkdocs.yml index 9a4ba4498..89cc885d8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -64,6 +64,7 @@ markdown_extensions: - pymdownx.highlight: pygments_lang_class: true - admonition + - pymdownx.snippets - pymdownx.superfences: custom_fences: - name: mermaid