@@ -25,6 +25,14 @@ RUN gpg --import /tmp/nginx_public_keys.key &&\
2525    rm /tmp/nginx_public_keys.key &&\
2626    /tmp/install-nginx
2727
28+ FROM  builder AS thpfoff_builder
29+ 
30+ #  This tool allows us to disable huge page support for our current process
31+ #  since the flag is preserved through forks and execs it can be used on any
32+ #  process
33+ ADD  thpoff.c /src/thpoff.c
34+ RUN  gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c
35+ 
2836FROM  discourse/ruby:3.3.6-${DEBIAN_RELEASE}-slim AS discourse_dependencies
2937
3038ARG  DEBIAN_RELEASE
@@ -51,14 +59,14 @@ RUN --mount=type=tmpfs,target=/var/log \
5159    echo "debconf debconf/frontend select Teletype"  | debconf-set-selections; \
5260    apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install gnupg sudo curl fping locales \
5361    ca-certificates rsync \
54-     cmake g++ pkg-config  patch \
55-     libxslt-dev  libcurl4-openssl-dev \
56-     libssl-dev libyaml-dev libtool  \
62+     patch \
63+     libcurl4-openssl-dev \
64+     libssl-dev libyaml-dev \
5765    libpcre3 libpcre3-dev zlib1g zlib1g-dev \
58-     libxml2-dev  gawk parallel  \
66+     gawk \
5967    libreadline-dev anacron wget \
6068    psmisc whois brotli libunwind-dev \
61-     libtcmalloc-minimal4 cmake  \
69+     libtcmalloc-minimal4 \
6270    pngcrush pngquant ripgrep poppler-utils \
6371#  imagemagick runtime dependencies
6472    libheif1 libjbig0 libtiff6 libpng16-16 libfontconfig1 \
@@ -133,11 +141,7 @@ RUN gem install pups --force &&\
133141    mkdir -p /pups/bin/ &&\
134142    ln -s /usr/local/bin/pups /pups/bin/pups
135143
136- #  This tool allows us to disable huge page support for our current process
137- #  since the flag is preserved through forks and execs it can be used on any
138- #  process
139- ADD  thpoff.c /src/thpoff.c
140- RUN  gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c
144+ COPY  --from=thpfoff_builder /usr/local/sbin/thpoff /usr/local/sbin/thpoff
141145
142146#  clean up for docker squash
143147RUN  rm -fr /usr/local/share/doc &&\
@@ -162,16 +166,23 @@ RUN install -dm 0755 -o discourse -g discourse /var/www/discourse &&\
162166    sudo -u discourse git clone --branch $DISCOURSE_BRANCH --filter=tree:0 https://github.com/discourse/discourse.git /var/www/discourse &&\
163167    gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }'  /var/www/discourse/Gemfile.lock)
164168
165- FROM  discourse_slim AS discourse_release
166- ENV  RAILS_ENV=production
169+ FROM  discourse_slim AS discourse_bundle_dependencies
167170
168- RUN  cd /var/www/discourse &&\
171+ RUN  apt update &&\
172+     apt install -y cmake g++ &&\
173+     cd /var/www/discourse &&\
169174    sudo -u discourse bundle config --local deployment true &&\
170175    sudo -u discourse bundle config --local path ./vendor/bundle &&\
171176    sudo -u discourse bundle config --local without test development &&\
172177    sudo -u discourse bundle install --jobs $(($(nproc) - 1)) &&\
173178    find /var/www/discourse/vendor/bundle -name cache -not -path '*/gems/*'  -type d -exec rm -rf {} + &&\
174179    find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
175180
181+ FROM  discourse_slim AS discourse_release
182+ ENV  RAILS_ENV=production
183+ 
184+ COPY  --from=discourse_bundle_dependencies /var/www/discourse/vendor/bundle /var/www/discourse/vendor/bundle
185+ COPY  --from=discourse_bundle_dependencies /home/discourse/.bundle /home/discourse/.bundle
186+ 
176187RUN  cd /var/www/discourse &&\
177188    sudo -u discourse /bin/bash -c 'if [ -f yarn.lock ]; then yarn install --frozen-lockfile && yarn cache clean; else pnpm install --frozen-lockfile; fi' 
0 commit comments