Skip to content

Commit

Permalink
Fix .bash_aliases to not to assume ~/IOTstack
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ukkopahis committed May 4, 2022
1 parent 5bcdfe8 commit c60b752
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
15 changes: 8 additions & 7 deletions .bash_aliases
Original file line number Diff line number Diff line change
@@ -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'
25 changes: 14 additions & 11 deletions docs/Basic_setup/Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ markdown_extensions:
- pymdownx.highlight:
pygments_lang_class: true
- admonition
- pymdownx.snippets
- pymdownx.superfences:
custom_fences:
- name: mermaid
Expand Down

0 comments on commit c60b752

Please sign in to comment.