@@ -72,14 +72,13 @@ RUN --mount=type=tmpfs,target=/var/log \
7272 echo "debconf debconf/frontend select Teletype" | debconf-set-selections; \
7373 apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install gnupg sudo curl fping locales \
7474 ca-certificates rsync \
75- cmake g++ pkg-config patch \
76- libxslt-dev libcurl4-openssl-dev \
77- libssl-dev libyaml-dev libtool \
78- libpcre3 libpcre3-dev zlib1g zlib1g-dev \
79- libxml2-dev gawk parallel \
80- libreadline-dev anacron wget \
81- psmisc whois brotli libunwind-dev \
82- libtcmalloc-minimal4 cmake \
75+ pkg-config patch \
76+ libtool \
77+ libpcre3 zlib1g \
78+ gawk parallel \
79+ anacron wget \
80+ psmisc whois brotli \
81+ libtcmalloc-minimal4 \
8382 pngcrush pngquant ripgrep poppler-utils \
8483# imagemagick runtime dependencies
8584 ghostscript libjbig0 libtiff6 libpng16-16 libfontconfig1 \
@@ -108,7 +107,7 @@ RUN --mount=type=tmpfs,target=/var/log \
108107 dpkg-divert --local --rename --add /sbin/initctl; \
109108 sh -c "test -f /sbin/initctl || ln -s /bin/true /sbin/initctl" ; \
110109 apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install runit socat \
111- libpq-dev postgresql-client-${PG_MAJOR} \
110+ postgresql-client-${PG_MAJOR} \
112111 nodejs yarn &&\
113112 mkdir -p /etc/runit/1.d
114113
@@ -169,21 +168,51 @@ RUN install -dm 0755 -o discourse -g discourse /var/www/discourse &&\
169168 sudo -u discourse git clone --branch $DISCOURSE_BRANCH --filter=tree:0 https://github.com/discourse/discourse.git /var/www/discourse &&\
170169 gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }' /var/www/discourse/Gemfile.lock)
171170
171+ FROM discourse_slim AS discourse_gem_builder
172+ RUN --mount=type=tmpfs,target=/var/log \
173+ apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
174+ cmake g++ \
175+ libxslt-dev libcurl4-openssl-dev \
176+ libssl-dev libyaml-dev \
177+ libpcre3-dev zlib1g-dev \
178+ libxml2-dev \
179+ libreadline-dev \
180+ libunwind-dev \
181+ libpq-dev
182+ RUN cd /var/www/discourse &&\
183+ sudo -u discourse bundle config --local deployment true &&\
184+ sudo -u discourse bundle config --local path ./vendor/bundle &&\
185+ sudo -u discourse bundle config --local without test development &&\
186+ sudo -u discourse bundle install --jobs $(($(nproc) - 1)) &&\
187+ find /var/www/discourse/vendor/bundle -name cache -not -path '*/gems/*' -type d -exec rm -rf {} + &&\
188+ find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} + &&\
189+ # Delete compile time libv8 library
190+ find /var/www/discourse/vendor/bundle -wholename "*libv8-node*/vendor" -type d -exec rm -rf {} +
191+
172192FROM discourse_slim AS discourse_web_only
173193ENV RAILS_ENV=production
174194
175195RUN cd /var/www/discourse &&\
176- sudo -u discourse bundle config --local deployment true &&\
177- sudo -u discourse bundle config --local path ./vendor/bundle &&\
178- sudo -u discourse bundle config --local without test development &&\
179- sudo -u discourse bundle install --jobs $(($(nproc) - 1)) &&\
180- find /var/www/discourse/vendor/bundle -name cache -not -path '*/gems/*' -type d -exec rm -rf {} + &&\
181- find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
196+ sudo -u discourse bundle config --local deployment true &&\
197+ sudo -u discourse bundle config --local path ./vendor/bundle &&\
198+ sudo -u discourse bundle config --local without test development
199+ COPY --from=discourse_gem_builder /var/www/discourse/vendor/bundle /var/www/discourse/vendor/bundle
182200
183201RUN cd /var/www/discourse &&\
184202 sudo -u discourse /bin/bash -c 'if [ -f yarn.lock ]; then yarn install --frozen-lockfile && yarn cache clean; else pnpm install --frozen-lockfile; fi'
185203
186204FROM discourse_web_only AS discourse_release
205+
206+ RUN --mount=type=tmpfs,target=/var/log \
207+ apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
208+ cmake g++ \
209+ libxslt-dev libcurl4-openssl-dev \
210+ libssl-dev libyaml-dev \
211+ libpcre3-dev zlib1g-dev \
212+ libxml2-dev \
213+ libreadline-dev \
214+ libunwind-dev \
215+ libpq-dev
187216RUN --mount=type=tmpfs,target=/var/log \
188217 apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
189218 postgresql-${PG_MAJOR} postgresql-contrib-${PG_MAJOR} postgresql-${PG_MAJOR}-pgvector
0 commit comments