# -*- ispell-local-dictionary: "english" -*-
#+SETUPFILE: ~/.emacs.d/etc/setup/latex.setup
#+SETUPFILE: ~/.emacs.d/etc/setup/html-readtheorg-local.setup

#+TITLE: Rocket.Chat

* Updating the charm to a new version

We are using official image. Latest tags usually.

** Test new version

Rocket.chat has a powerfull and working database update mecanism that
will take care of migrating database on startup *as long as you jump only
from one major version to the next*.

*** Get latest available versions

You can double-check available candidate for official images like this:

#+begin_src sh
docker-tags-fetch rocketchat/rocket.chat -l 15 -f "^[0-9]+\.[0-9]+\.[0-9]+$" | sort -rV
#+end_src

Check/Choose the version you want to test.

*** Modify your own =compose.yml=

By adding these 2 lines in your rocket chat service:

#+begin_src yaml
  docker-compose:
    image: rocketchat/rocket.chat:X.Y.Z
#+end_src

Replace X.Y.Z by the target version you want to test.

Launch =compose up=.

Be ready to wait a few minutes after =compose up= finished before the
service to be available: rocketchat is expected to take some time to
migrate.


** Change the current charm to include new version

To prepare the commit for next version, you can run the following
on the repository you'll use to push the new commit.

#+begin_src sh
BASENAME=rocketchat/rocket.chat
VERSION=$(docker-tags-fetch "$BASENAME" -l 15 -f "^[0-9]+\.[0-9]+\.[0-9]+$" | sort -rV | head -n 1)
echo Last version of rocket chat: $VERSION
docker pull rocketchat/rocket.chat:"$VERSION" &&
docker tag rocketchat/rocket.chat:"$VERSION" docker.0k.io/rocketchat:"$VERSION" &&
docker push docker.0k.io/rocketchat:"$VERSION" &&
sed -ri "s%^(docker-image: docker.0k.io/rocketchat:).*%\1$VERSION%" metadata.yml &&
sed -ri "s%^(#docker-image: rocketchat/rocket.chat:).*%\1$VERSION%" metadata.yml
#+end_src

You can review the changes and commit them.