Atualize manualmente o Discourse e a imagem Docker para a mais recente

:bookmark: This guide provides step-by-step instructions for manually updating Discourse, the Docker container, and the Ubuntu operating system on a self-hosted setup.

:person_raising_hand: Required user level: System Administrator

:warning: SSH access to the server.

If you self-host Discourse, you occasionally need to run a manual update via the command line to get the latest security releases newest libraries.

These updates are not picked up in admin/update, which is why you’ll occasionally need to do these additional steps:

Updating Discourse

  1. Discourse itself should be updated about twice a month, by clicking the “Update to Latest Version” button in your admin dashboard (admin/update).

  2. Every two months we recommend SSH’ing into your web server (using putty or your favorite SSH client) and running the following commands, especially if the upgrade page doesn’t show up or you have any issues when trying to upgrade.

cd /var/discourse
./launcher rebuild app

Updating the Docker image and Ubuntu OS

For Ubuntu updates, make sure you have automatic security updates enabled for your Ubuntu! The command is:

dpkg-reconfigure -plow unattended-upgrades

However, that just covers critical security updates. Every so often you should get all the OS updates like so:

apt-get update
apt-get dist-upgrade

Due to the way docker packaging has changed you may also have to update your docker from lxc-docker or docker-engine packages. One way to do that is via the Docker script here (it will warn about an existing install but should upgrade ok):

wget -qO- https://get.docker.com/ | sh

This will now use the docker-ce main versions.

To summarize:

  • update Discourse twice a month via web updater
  • update the container every two months
  • update the OS every six months

You could double these numbers and still be fairly safe, e.g. update Discourse once a month, container every 4 months, OS once every 12 months, and so on.

But you really, really want automatic security updates enabled in Ubuntu, as listed above.

FAQ

What is the right time to update?

It just depends on the time you have available and how close to bleeding edge you want to be. If you have non-official plugins, it is highly advisable to utilize a test/staging site. If you do not have any non-official plugins, you can likely upgrade immediately, but even then, some plugins may break for a couple of days as the team fixes them (there are a lot of them).

What is common practice when updating with many plugins installed?

If you have a lot of plugins, testing locally or on a test server is highly advised. Especially if you have non-official plugins, as something could have broken. If you find something does break, then it is a matter of, do you have time to fix it? Does the original plugin author have time to fix it? Either of those could take weeks. So at least this way, you simply have a broken test site and not a broken production site.

I’m running low on disk space

If you are running low on disk space (check with df) try clearing up old images using:

./launcher cleanup
apt-get autoclean
apt-get autoremove

Does updating the actual server version of Ubuntu matter since Discourse always operates in Docker?

It matters a lot less. But you should be on at least a currently supported LTS release of Ubuntu server. A 64-bit Linux OS with a modern kernel version is required.

Last edited by @SaraDev 2024-11-21T21:25:01Z

Check documentPerform check on document:
177 curtidas

Os guias sĂŁo revisados e atualizados com bastante frequĂȘncia (este parece ter tido um pequeno ajuste em fevereiro). :+1:

O Ășnico que eu pessoalmente nĂŁo conheço Ă© o do docker:

Mas posso garantir a precisĂŁo do resto. :slight_smile:

3 curtidas

Acabei de executar todos esses comandos no meu site de teste, incluindo a atualização do Docker, e eles funcionaram sem problemas.

5 curtidas

Recebi um relato de que isso causou um problema ao ser executado. Acho que nunca o usei nos Ășltimos dois anos em que tive um site de teste DO.

AlguĂ©m tem alguma experiĂȘncia recente com isso para dizer se ainda Ă© um conselho relevante ou nĂŁo?


Acabei de dar uma olhada nas postagens excluĂ­das e encontrei algumas onde essa parte do guia foi levantada antes [1] e parece que @MarkDoerr a executou sem problemas.

Embora eu ainda nĂŁo tenha certeza se/em quais circunstĂąncias vocĂȘ seria obrigado a executĂĄ-lo? Tenho muita fĂ© no Docker Manager?


  1. Eu as restaurei ↩

2 curtidas

2 posts foram divididos para um novo tĂłpico: Quando atualizar o contĂȘiner de dados de uma configuração de dois contĂȘineres?

Um post foi dividido em um novo tópico: Atualizando o fórum v2.2.0.beta4 com alteraçÔes locais desconhecidas

Tentei executar esse comando (wget -qO- https://get.docker.com/ | sh) agora e ele relata:

Não é possível conectar ao daemon do Docker em unix:///var/run/docker.sock. O daemon do docker estå em execução?

Parece que isso nĂŁo funcionou para atualizar o docker.

Também parece ter causado a falha completa do site, e o aplicativo não pode ser reconstruído, relatando:

NĂŁo Ă© possĂ­vel conectar ao daemon do docker - verifique se ele estĂĄ em execução e se vocĂȘ tem acesso

ApĂłs reiniciar o servidor, o site voltou a ficar online.

EntĂŁo, talvez ele tenha feito o upgrade, mas falhou ao reiniciar o docker. VocĂȘ pode verificar com

docker --version

Acontece que meu laptop tinha um docker antigo e eu executei o comando recomendado e nĂŁo precisei reiniciar para que ele funcionasse. Veja o que obtenho para a versĂŁo:

$ docker --version
Docker version 26.1.4, build 5650f9b
1 curtida

Tenha a mesma versĂŁo do Docker:

Docker version 26.1.4, build 5650f9b
1 curtida

EntĂŁo vocĂȘ estĂĄ atualizado e tudo estĂĄ bem!

3 curtidas

Eu sabia que tinha visto este documento cobrindo a cadĂȘncia de atualização do Discourse, mas tive dificuldade em encontrĂĄ-lo novamente porque estĂĄ em Documentation em “Usando Docker” e intitulado “Atualizar Docker manualmente”.

Como ele cobre as atualizaçÔes do Discourse e do Ubuntu, ele poderia ter outro lugar ou dois no menu?

1 curtida

Quando o Discourse recomenda que vocĂȘ atualize uma imagem (de modo que nĂŁo seja possĂ­vel atualizar pela interface do usuĂĄrio), ele informa para fazer o seguinte:

    cd /var/discourse
    git pull
    ./launcher rebuild app

Para que serve esse git pull adicional e por que vocĂȘ nĂŁo o recomenda no manual?

3 curtidas

É uma relĂ­quia antiga e nĂŁo Ă© mais necessĂĄria. O Rebuild faz isso.

2 curtidas

Eu faço um PR?

3 curtidas
6 curtidas

Mesclado, obrigado @tvavrda!

6 curtidas