# Como posso minimizar o tamanho da imagem Docker do Discourse?

**URL:** <https://meta.discourse.org/t/how-can-i-minimize-the-discourse-docker-image-size/378249>\
**Category:** Self-hosting\
**Created:** [Agosto 12, 2025, 6:19am UTC](https://meta.discourse.org/t/how-can-i-minimize-the-discourse-docker-image-size/378249 "2025-08-12T06:19:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![elmuerte](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elmuerte/32/456517_2.png) [@elmuerte](https://meta.discourse.org/u/elmuerte)\
**Post date:** [Agosto 12, 2025, 3:29pm UTC](https://meta.discourse.org/t/how-can-i-minimize-the-discourse-docker-image-size/378249/5 "2025-08-12T15:29:38Z")

</div>

A imagem slim ainda inclui postgres e redis.

A diferença entre slim e as outras começa no comando 37. Os seguintes comandos não são executados no slim:

```plaintext
ENV RAILS_ENV=production
RUN |3 DEBIAN_RELEASE=bookworm PG_MAJOR=15 DISCOURSE_BRANCH=main /bin/sh -c cd /var/www/discourse & sudo -u discourse bundle config --local deployment true & sudo -u discourse bundle config --local path ./vendor/bundle & sudo -u discourse bundle config --local without test development & sudo -u discourse bundle install --jobs $(($(nproc) - 1)) & find /var/www/discourse/vendor/bundle -name cache -not -path '*/gems/*' -type d -exec rm -rf {} + & find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} + # buildkit
RUN |3 DEBIAN_RELEASE=bookworm PG_MAJOR=15 DISCOURSE_BRANCH=main /bin/sh -c cd /var/www/discourse & sudo -u discourse /bin/bash -c 'if [-f yarn.lock]; then yarn install --frozen-lockfile & yarn cache clean; else pnpm install --frozen-lockfile; fi' # buildkit

```

Basicamente, faltam algumas etapas de compilação. Não há `bundle install` nem `pnpm install`. Coisas que você eventualmente precisará.

As grandes dores estão no comando 11: 390MiB

```plaintext
RUN |2 DEBIAN_RELEASE=bookworm PG_MAJOR=15 /bin/sh -c echo "debconf debconf/frontend select Teletype" | debconf-set-selections; apt-get -y update & DEBIAN_FRONTEND=noninteractive apt-get -y install gnupg sudo curl fping locales ca-certificates rsync cmake g++ pkg-config patch libxslt-dev libcurl4-openssl-dev libssl-dev libyaml-dev libtool libpcre3 libpcre3-dev zlib1g zlib1g-dev libxml2-dev gawk parallel libreadline-dev anacron wget psmisc whois brotli libunwind-dev libtcmalloc-minimal4 cmake pngcrush pngquant ripgrep poppler-utils ghostscript libjbig0 libtiff6 libpng16-16 libfontconfig1 libwebpdemux2 libwebpmux3 libxext6 librsvg2-2 libgomp1 fonts-urw-base35 libheif1/${DEBIAN_RELEASE}-backports nginx-common & DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends git rsyslog logrotate cron ssh-client less; install -d /usr/share/postgresql-common/pgdg & curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc & echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${DEBIAN_RELEASE}-pgdg main" > /etc/apt/sources.list.d/pgdg.list; curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list; curl --silent --location https://deb.nodesource.com/setup_22.x | sudo bash -; sed -i -e 's/start -q anacron/anacron -s/' /etc/cron.d/anacron; sed -i.bak 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf; sed -i.bak 's/module(load="imklog")/#module(load="imklog")/' /etc/rsyslog.conf; dpkg-divert --local --rename --add /sbin/initctl; sh -c "test -f /sbin/initctl || ln -s /bin/true /sbin/initctl"; apt-get -y update & DEBIAN_FRONTEND=noninteractive apt-get -y install runit socat libpq-dev postgresql-client-${PG_MAJOR} postgresql-${PG_MAJOR} postgresql-contrib-${PG_MAJOR} postgresql-${PG_MAJOR}-pgvector nodejs yarn & mkdir -p /etc/runit/1.d # buildkit

```

Ele instala muitas ferramentas necessárias para outras partes, e também postgresql:

> gnupg sudo curl fping locales ca-certificates rsync cmake g++ pkg-config patch libxslt-dev libcurl4-openssl-dev libssl-dev libyaml-dev libtool libpcre3 libpcre3-dev zlib1g zlib1g-dev libxml2-dev gawk parallel libreadline-dev anacron wget psmisc whois brotli libunwind-dev libtcmalloc-minimal4 cmake pngcrush pngquant ripgrep poppler-utils ghostscript libjbig0 libtiff6 libpng16-16 libfontconfig1 libwebpdemux2 libwebpmux3 libxext6 librsvg2-2 libgomp1 fonts-urw-base35 libheif1 nginx-common git rsyslog logrotate cron ssh-client less runit socat libpq-dev postgresql-client postgresql postgresql-contrib postgresql-pgvector nodejs yarn

---

_[View the full topic](https://meta.discourse.org/t/how-can-i-minimize-the-discourse-docker-image-size/378249)._
