From a7533c3eb12a3a739db8acc15309a9aae2ff4087 Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Mon, 26 Nov 2018 19:46:10 +0100 Subject: [PATCH] reorganize + update v2.2.0beta4 --- Dockerfile | 108 +++++++++++++++++++++++++++++--------------- install-gifsicle | 11 +++++ install-imagemagick | 46 +++++++++++++++++++ install-pngcrush | 11 +++++ install-pngquant | 8 ++++ 5 files changed, 147 insertions(+), 37 deletions(-) create mode 100755 install-gifsicle create mode 100755 install-imagemagick create mode 100755 install-pngcrush create mode 100755 install-pngquant diff --git a/Dockerfile b/Dockerfile index 0e54ffd..4ee7605 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ -FROM ruby:2.4.1 +FROM ruby:2.5.3 ENV RAILS_ENV=production \ - RUBY_GC_MALLOC_LIMIT=90000000 \ - RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \ DISCOURSE_DB_HOST=postgres \ DISCOURSE_REDIS_HOST=redis \ DISCOURSE_SERVE_STATIC_ASSETS=true \ - GIFSICLE_VERSION=1.88 \ - PNGQUANT_VERSION=2.8.0 \ - DISCOURSE_VERSION=2.2.0.beta2 \ + GIFSICLE_VERSION=1.91 \ + PNGQUANT_VERSION=2.12.1 \ + PNGCRUSH_VERSION=1.8.13 \ + DISCOURSE_VERSION=2.2.0.beta4 \ + PG_MAJOR=10 \ BUILD_DEPS="\ autoconf \ - jhead \ + advancecomp \ libbz2-dev \ libfreetype6-dev \ libjpeg-dev \ @@ -19,14 +19,11 @@ ENV RAILS_ENV=production \ libtiff-dev \ pkg-config" +RUN curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" | \ + tee /etc/apt/sources.list.d/postgres.list -RUN addgroup --gid 1000 discourse \ - && adduser --system --uid 1000 --ingroup discourse --shell /bin/bash discourse \ - && cd /home/discourse \ - && mkdir -p ./tmp/sockets \ - && git clone --branch v${DISCOURSE_VERSION} https://github.com/discourse/discourse.git \ - && chown -R discourse:discourse . \ - && curl --silent --location https://deb.nodesource.com/setup_8.x | bash - \ +RUN curl --silent --location https://deb.nodesource.com/setup_8.x | bash - \ && apt-get update && apt-get install -y --no-install-recommends \ ${BUILD_DEPS} \ ghostscript \ @@ -36,36 +33,73 @@ RUN addgroup --gid 1000 discourse \ libxml2 \ nodejs \ optipng \ - && npm install svgo uglify-js@"<3" -g \ - && cd /tmp \ - && curl -O http://www.lcdf.org/gifsicle/gifsicle-$GIFSICLE_VERSION.tar.gz \ - && tar zxf gifsicle-$GIFSICLE_VERSION.tar.gz \ - && cd gifsicle-$GIFSICLE_VERSION \ - && ./configure && make install \ - && cd /tmp \ - && rm gifsicle-$GIFSICLE_VERSION.tar.gz \ - && rm -rf gifsicle-$GIFSICLE_VERSION \ - && git clone -b $PNGQUANT_VERSION --single-branch https://github.com/pornel/pngquant \ - && cd pngquant \ - && make && make install \ - && rm -rf pngquant \ + jhead \ + postgresql-client-${PG_MAJOR} \ + postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev + +RUN npm install svgo uglify-js@"<3" -g + +RUN mkdir /jemalloc-stable && cd /jemalloc-stable &&\ + wget https://github.com/jemalloc/jemalloc/releases/download/3.6.0/jemalloc-3.6.0.tar.bz2 &&\ + tar -xjf jemalloc-3.6.0.tar.bz2 && cd jemalloc-3.6.0 && ./configure --prefix=/usr && make && make install &&\ + cd / && rm -rf /jemalloc-stable + +RUN mkdir /jemalloc-new && cd /jemalloc-new &&\ + wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2 &&\ + tar -xjf jemalloc-5.1.0.tar.bz2 && cd jemalloc-5.1.0 && ./configure --prefix=/usr --with-install-suffix=5.1.0 && make build_lib && make install_lib &&\ + cd / && rm -rf /jemalloc-new + + +RUN gem update --system + +RUN gem install bundler --force \ + && rm -rf /usr/local/share/ri/2.5.2/system + +ADD install-imagemagick /tmp/install-imagemagick +RUN /tmp/install-imagemagick + +# Validate install +RUN ruby -Eutf-8 -e "v = \`convert -version\`; %w{png tiff jpeg freetype}.each { |f| unless v.include?(f); STDERR.puts('no ' + f + ' support in imagemagick'); exit(-1); end }" + +ADD install-pngcrush /tmp/install-pngcrush +RUN /tmp/install-pngcrush + +ADD install-gifsicle /tmp/install-gifsicle +RUN /tmp/install-gifsicle + +ADD install-pngquant /tmp/install-pngquant +RUN /tmp/install-pngquant + +RUN addgroup --gid 1000 discourse \ + && adduser --system --uid 1000 --ingroup discourse --shell /bin/bash discourse \ + && cd /home/discourse \ + && mkdir -p tmp/pids \ + && mkdir -p ./tmp/sockets \ + && git clone --branch v${DISCOURSE_VERSION} https://github.com/discourse/discourse.git \ + && chown -R discourse:discourse . \ && cd /home/discourse/discourse \ && git remote set-branches --add origin tests-passed \ && sed -i 's/daemonize true/daemonize false/g' ./config/puma.rb \ && bundle config build.nokogiri --use-system-libraries \ - && bundle install --deployment --without test --without development \ - && cd /tmp \ - && curl -O https://get.enterprisedb.com/postgresql/postgresql-9.5.9-1-linux-x64-binaries.tar.gz \ - && tar zxf postgresql-9.5.9-1-linux-x64-binaries.tar.gz \ - && mv ./pgsql/bin/* /usr/local/bin/ \ - && rm postgresql-9.5.9-1-linux-x64-binaries.tar.gz \ - && rm -rf ./pgsql \ - && apt-get remove -y --purge ${BUILD_DEPS} \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* + && bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4 + +RUN find /home/discourse/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} + + +# RUN apt-get remove -y --purge ${BUILD_DEPS} \ +# && apt-get autoremove -y \ +# && rm -rf /var/lib/apt/lists/* + +RUN rm -rf /var/lib/apt/lists/* WORKDIR /home/discourse/discourse +ENV RAILS_ENV=production \ + RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \ + RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 \ + RUBY_GC_HEAP_INIT_SLOTS=400000 \ + RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 \ + RUBY_GC_MALLOC_LIMIT=90000000 + USER discourse CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"] diff --git a/install-gifsicle b/install-gifsicle new file mode 100755 index 0000000..e35be3c --- /dev/null +++ b/install-gifsicle @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +VERSION=1.91 +cd /tmp +curl -O http://www.lcdf.org/gifsicle/gifsicle-$VERSION.tar.gz +tar zxf gifsicle-$VERSION.tar.gz +cd gifsicle-$VERSION +./configure +make install +cd / +rm -fr /tmp/gifsicle* diff --git a/install-imagemagick b/install-imagemagick new file mode 100755 index 0000000..f0e99e3 --- /dev/null +++ b/install-imagemagick @@ -0,0 +1,46 @@ +#!/bin/bash +set -o errexit + +# Install build deps +apt-get -y -q remove imagemagick + +PREFIX=/usr/local +WDIR=/tmp/imagemagick +mkdir -p $WDIR + +# Build and install libpng +git clone -b v1.6.34 https://github.com/glennrp/libpng.git $WDIR/libpng +cd $WDIR/libpng +./autogen.sh +./configure --prefix=$PREFIX +make all && make install + +# Build and install ImageMagick +wget -O $WDIR/ImageMagick.tar.gz "https://github.com/ImageMagick/ImageMagick/archive/7.0.8-6.tar.gz" +IMDIR=$WDIR/$(tar tzf $WDIR/ImageMagick.tar.gz --wildcards "ImageMagick-*/configure" |cut -d/ -f1) +tar zxf $WDIR/ImageMagick.tar.gz -C $WDIR +cd $IMDIR +PKG_CONF_LIBDIR=$PREFIX/lib LDFLAGS=-L$PREFIX/lib CFLAGS=-I$PREFIX/include ./configure \ + --prefix=$PREFIX \ + --enable-static \ + --enable-bounds-checking \ + --enable-hdri \ + --enable-hugepages \ + --with-threads \ + --with-modules \ + --with-quantum-depth=16 \ + --without-magick-plus-plus \ + --with-bzlib \ + --with-zlib \ + --without-autotrace \ + --with-freetype \ + --with-jpeg \ + --without-lcms \ + --with-lzma \ + --with-png \ + --with-tiff +make all && make install + +cd $HOME +rm -rf $WDIR +ldconfig /usr/local/lib diff --git a/install-pngcrush b/install-pngcrush new file mode 100755 index 0000000..a08b2b6 --- /dev/null +++ b/install-pngcrush @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +PNGCRUSH_VERSION=1.8.13 +cd /tmp +wget https://sourceforge.net/projects/pmt/files/pngcrush/$PNGCRUSH_VERSION/pngcrush-$PNGCRUSH_VERSION.tar.gz/download -O pngcrush-$PNGCRUSH_VERSION.tar.gz +tar zxf pngcrush-$PNGCRUSH_VERSION.tar.gz +cd pngcrush-$PNGCRUSH_VERSION +make && cp -f pngcrush /usr/local/bin +cd / +rm -fr /tmp/pngcrush-$PNGCRUSH_VERSION +rm /tmp/pngcrush-$PNGCRUSH_VERSION.tar.gz diff --git a/install-pngquant b/install-pngquant new file mode 100755 index 0000000..2a21c8a --- /dev/null +++ b/install-pngquant @@ -0,0 +1,8 @@ +#!/bin/bash +VERSION=2.12.1 +cd /tmp +git clone -b $VERSION --single-branch https://github.com/pornel/pngquant +cd pngquant +make && make install +cd / +rm -fr /tmp/pngq* -- GitLab